Mercurial > hg > Database > Alice
diff src/main/java/alice/datasegment/MulticastDataSegmentManager.java @ 360:6cf08aebfc31 multicast
add MulticastConnection and DataSegmentManager
author | sugi |
---|---|
date | Thu, 15 May 2014 15:44:22 +0900 |
parents | |
children | 60eee1fb0fd3 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Thu May 15 15:44:22 2014 +0900 @@ -0,0 +1,106 @@ +package alice.datasegment; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.StandardProtocolFamily; +import java.net.StandardSocketOptions; +import java.nio.channels.DatagramChannel; +import org.apache.log4j.Logger; + +import alice.codesegment.CodeSegment; +import alice.daemon.Connection; + +public class MulticastDataSegmentManager extends DataSegmentManager { + Connection connection; + Logger logger; + + public MulticastDataSegmentManager(final String MCASTADDR, final int port, final String nis) { + logger = Logger.getLogger("multicast"); + connection = new Connection(); + DatagramChannel dc = createDatagramChannel(MCASTADDR, port, nis); + + } + + private DatagramChannel createDatagramChannel(String MCASTADDR, int port, String nis) { + DatagramChannel dc = null; + NetworkInterface ni; + try { + ni = NetworkInterface.getByName(nis); + if (ni==null) { + System.err.println("Can't open network interface "+nis); + throw new IOException(); + } + if (!ni.supportsMulticast()) { + System.err.println("Network interface does not support multicast"+nis); + throw new IOException(); + } + + dc = DatagramChannel.open(StandardProtocolFamily.INET); + dc.setOption(StandardSocketOptions.SO_REUSEADDR, true); + dc.setOption(StandardSocketOptions.IP_MULTICAST_IF, ni); + InetAddress group = InetAddress.getByName(MCASTADDR); + dc.join(group, ni); + } catch (Exception e) { + e.printStackTrace(); + } + return dc; + } + + @Override + public void put(String key, Object val) { + + } + + @Override + public void update(String key, Object val) { + + } + + @Override + public void take(Receiver receiver, CodeSegment cs) {} + @Override + public void peek(Receiver receiver, CodeSegment cs) {} + + @Override + public void quickPut(String key, Object val) { + + } + + @Override + public void quickUpdate(String key, Object val) { + + } + + @Override + public void quickPeek(Receiver receiver, CodeSegment cs) {} + @Override + public void quickTake(Receiver receiver, CodeSegment cs) {} + + @Override + public void remove(String key) { + + } + + @Override + public void shutdown() { + + } + + @Override + public void close() { + + } + + @Override + public void finish() { + + } + + @Override + public void ping(String returnKey) {} + + @Override + public void response(String returnKey) {} + +}