view src/alice/test/codesegment/TestRemoteAlice.java @ 17:bb075e103cd3

bug fix for take()
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Jan 2012 15:18:01 +0900
parents 433e601a8e28
children e7867328a2fb
line wrap: on
line source

package alice.test.codesegment;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;

import alice.codesegment.CodeSegment;
import alice.daemon.AliceDaemon;
import alice.daemon.Config;
import alice.daemon.Connection;
import alice.datasegment.DataSegment;
import alice.datasegment.RemoteDataSegmentManager;

public class TestRemoteAlice {

	public static void main(String[] args) {
		Config conf = new Config(args);

		final AliceDaemon daemon = new AliceDaemon(conf);
		new Thread() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				daemon.listen();
			}
			
		}.start();
		
		boolean connect = true;
		do {
			try {
				SocketChannel sc = SocketChannel.open(new InetSocketAddress(conf.hostname, conf.connectPort));
				Connection connection = new Connection(sc.socket());
				RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connection);
				DataSegment.regist(conf.key, manager);
				connect = false;
			} catch (IOException e) {
				try {
					Thread.sleep(500);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
			}
		} while (connect);
		
		CodeSegment cs = new RemoteStartCodeSegment();
		cs.ids.execute();
	}

}