当前位置: 首页>>代码示例>>Java>>正文


Java NettyNetwork类代码示例

本文整理汇总了Java中se.sics.kompics.network.netty.NettyNetwork的典型用法代码示例。如果您正苦于以下问题:Java NettyNetwork类的具体用法?Java NettyNetwork怎么用?Java NettyNetwork使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NettyNetwork类属于se.sics.kompics.network.netty包,在下文中一共展示了NettyNetwork类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Receiver

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public Receiver(Init init) {
    resultQ = init.resultQ;
    self = init.self;
    outputDirectory = init.outputDirectory;

    timeC = create(JavaTimer.class, Init.NONE);
    netC = create(NettyNetwork.class, new NettyInit(init.self));
    connect(net.getPair(), netC.getPositive(Network.class));
    vnc = VirtualNetworkChannel.connect(net, proxy);
    flowC = create(FlowManager.class, new FlowManagerInit(init.bufferSize, init.minAlloc, init.maxAlloc, Transport.TCP, init.protocol, init.self));
    vnc.addConnection(null, flowC.getNegative(Network.class));
    connect(flowC.getNegative(Timer.class), timeC.getPositive(Timer.class));

    // subscriptions
    subscribe(initHandler, net);
    subscribe(startHandler, control);
    subscribe(pingHandler, net);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:19,代码来源:Receiver.java

示例2: ClientParent

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public ClientParent(Init init) {

        Component node = create(Client.class, new Client.Init(init.self, init.member));
        Component input = create(InputGen.class, se.sics.kompics.Init.NONE);

        if (init.deploy) {
            connect(node.getNegative(Network.class), create(NettyNetwork.class, new NettyInit(init.self)).getPositive(Network.class), Channel.TWO_WAY);
            connect(node.getNegative(Timer.class), create(JavaTimer.class, Init.NONE).getPositive(Timer.class), Channel.TWO_WAY);
        } else {
            connect(node.getNegative(Network.class), requires(Network.class), Channel.TWO_WAY);
            connect(node.getNegative(Timer.class), requires(Timer.class), Channel.TWO_WAY);
        }

        connect(input.getNegative(InputGenPort.class), node.getPositive(InputGenPort.class), Channel.TWO_WAY);
    }
 
开发者ID:tobiajo,项目名称:jbstore,代码行数:16,代码来源:ClientParent.java

示例3: NodeParent

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public NodeParent(Init init) {

        Component node = create(Node.class, new Node.Init(init.self, init.member, init.id, init.n));
        if (init.deploy) {
            connect(node.getNegative(Network.class), create(NettyNetwork.class, new NettyInit(init.self)).getPositive(Network.class), Channel.TWO_WAY);
        } else {
            connect(node.getNegative(Network.class), requires(Network.class), Channel.TWO_WAY);                         // Node <-> Network
        }

        Component viewSync = create(ViewSync.class, se.sics.kompics.Init.NONE);
        connect(viewSync.getNegative(ViewSyncPort.class), node.getPositive(ViewSyncPort.class), Channel.ONE_WAY_NEG);   // Node --> ViewSync
        connect(viewSync.getNegative(NodePort.class), node.getPositive(NodePort.class), Channel.ONE_WAY_POS);           // Node <-- ViewSync

        Component epfd = create(EPFD.class, se.sics.kompics.Init.NONE);
        if (init.deploy) {
            connect(epfd.getNegative(Timer.class), create(JavaTimer.class, Init.NONE).getPositive(Timer.class), Channel.TWO_WAY);
        } else {
            connect(epfd.getNegative(Timer.class), requires(Timer.class), Channel.TWO_WAY);                             // EPDF <-> Timer
        }
        connect(epfd.getNegative(EPFDPort.class), node.getPositive(EPFDPort.class), Channel.ONE_WAY_NEG);               // EPDF <-- Node
        connect(epfd.getNegative(NodePort.class), node.getPositive(NodePort.class), Channel.ONE_WAY_POS);               // EPDF --> Node
        connect(epfd.getNegative(EPFDPort.class), viewSync.getPositive(EPFDPort.class), Channel.TWO_WAY);               // EPDF <-> ViewSync

        Component kvStore = create(KVStore.class, se.sics.kompics.Init.NONE);
        connect(kvStore.getNegative(KVStorePort.class), node.getPositive(KVStorePort.class), Channel.ONE_WAY_NEG);      // KVStore <-- Node
        connect(kvStore.getNegative(NodePort.class), node.getPositive(NodePort.class), Channel.ONE_WAY_POS);            // KVStore --> Node
        connect(kvStore.getNegative(KVStorePort.class), viewSync.getPositive(KVStorePort.class), Channel.ONE_WAY_NEG);  // KVStore <-- ViewSync
    }
 
开发者ID:tobiajo,项目名称:jbstore,代码行数:29,代码来源:NodeParent.java

示例4: PingerParent

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public PingerParent(Init init) {
    Component timer = create(JavaTimer.class, Init.NONE);
    Component network = create(NettyNetwork.class, new NettyInit(init.self));
    Component pinger = create(Pinger.class, new Pinger.Init(init.self, init.ponger));

    connect(pinger.getNegative(Timer.class), timer.getPositive(Timer.class), Channel.TWO_WAY);

    connect(pinger.getNegative(Network.class), network.getPositive(Network.class), Channel.TWO_WAY);
}
 
开发者ID:tobiajo,项目名称:jbstore,代码行数:10,代码来源:PingerParent.java

示例5: ClientManager

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public ClientManager() {
    if (INSTANCE == null) {
        INSTANCE = this; // will work in Oracle JDK...Not sure about other implementations
    } else {
        throw new RuntimeException("Don't start the ClientManager twice! You are doing it wrong -.-");
    }
    if (conf == null) {
        conf = ConfigFactory.load();
    }
    sampleSize = conf.getInt("bootstrap.sampleSize");
    useLUT = conf.getBoolean("client.fetchLUT");
    String ipStr = conf.getString("bootstrap.address.hostname");
    String localHost = conf.getString("client.address.hostname");
    int bootPort = conf.getInt("bootstrap.address.port");
    int localPort = conf.getInt("client.address.port");
    InetAddress localIP = null;
    InetAddress bootIp = null;
    try {
        bootIp = InetAddress.getByName(ipStr);
        localIP = InetAddress.getByName(localHost);
    } catch (UnknownHostException ex) {
        throw new RuntimeException(ex.getMessage());
    }
    bootstrapServer = new Address(bootIp, bootPort, null);
    self = new Address(localIP, localPort, null);
    TimestampIdFactory.init(self);

    lut = new ReadOnlyLUT(self, RAND);

    network = create(NettyNetwork.class, new NettyInit(self));
    timer = create(JavaTimer.class, Init.NONE);
    vnc = VirtualNetworkChannel.connect(network.getPositive(Network.class), proxy);
    vnc.addConnection(null, net.getPair());

    subscribe(startHandler, control);
    subscribe(partHandler, net);
    subscribe(responseHandler, net);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:39,代码来源:ClientManager.java

示例6: Parent

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public Parent() {
    Component sender = create(Sender.class, Init.NONE);
    Component receiver = create(Receiver.class, Init.NONE);
    Component senderNetty = create(NettyNetwork.class, new NettyInit(MsgSizeTest.senderAddr));
    Component receiverNetty = create(NettyNetwork.class, new NettyInit(MsgSizeTest.receiverAddr));
    connect(sender.getNegative(Network.class), senderNetty.getPositive(Network.class));
    connect(receiver.getNegative(Network.class), receiverNetty.getPositive(Network.class));
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:9,代码来源:Parent.java

示例7: PongerParent

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
public PongerParent(Init init) {
    Component network = create(NettyNetwork.class, new NettyInit(init.self));
    Component ponger = create(Ponger.class, new Ponger.Init(init.self));

    connect(ponger.getNegative(Network.class), network.getPositive(Network.class), Channel.TWO_WAY);
}
 
开发者ID:tobiajo,项目名称:jbstore,代码行数:7,代码来源:PongerParent.java

示例8: connect

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
private void connect() {
    timerComp = create(JavaTimer.class, Init.NONE);
    networkComp = create(NettyNetwork.class, new NettyInit(selfAdr));

    StreamHostComp.ExtPort extPorts = new StreamHostComp.ExtPort(timerComp.getPositive(Timer.class), networkComp.getPositive(Network.class));
    TorrentDetails torrentDetails;
    torrentDetails = new TorrentDetails() {
        private final String torrentName = experimentConfig.torrentName;
        private final String filePath = inputDir + File.separator + experimentConfig.torrentName;
        private final String hashPath = inputDir + File.separator + experimentConfig.torrentName + ".hash";
        private final Torrent torrent;
        private final Triplet<FileMngr, HashMngr, TransferMngr> mngrs;

        {
            try {
                File dataFile = new File(filePath);
                if (!dataFile.exists()) {
                    throw new RuntimeException("missing data file:" + filePath);
                }
                File hashFile = new File(hashPath);
                if (!hashFile.exists()) {
                    throw new RuntimeException("missing hash file:" + hashPath);
                }

                int pieceSize = 1024;
                int piecesPerBlock = 1024;
                int blockSize = pieceSize * piecesPerBlock;

                long fileSize = dataFile.length();
                long hashFileSize = hashFile.length();

                String hashAlg = HashUtil.getAlgName(HashUtil.SHA);
                int hashSize = HashUtil.getHashSize(hashAlg);

                torrent = new Torrent(experimentConfig.torrentId, FileInfo.newFile(torrentName, fileSize), new TorrentInfo(pieceSize, piecesPerBlock, hashAlg, hashFileSize));
                FileMngr fileMngr = StorageMngrFactory.completeMMFileMngr(filePath, fileSize, blockSize, pieceSize);
                HashMngr hashMngr = StorageMngrFactory.completeMMHashMngr(hashPath, hashAlg, hashFileSize, hashSize);
                mngrs = Triplet.with(fileMngr, hashMngr, null);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }

        @Override
        public Identifier getOverlayId() {
            return torrent.overlayId;
        }

        @Override
        public boolean download() {
            return false;
        }

        @Override
        public Torrent getTorrent() {
            return torrent;
        }

        @Override
        public Triplet<FileMngr, HashMngr, TransferMngr> torrentMngrs(Torrent torrent) {
            return mngrs;
        }
    };
    streamComp = create(StreamHostComp.class, new StreamHostComp.Init(extPorts, selfAdr, torrentDetails, new ArrayList<KAddress>()));
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:66,代码来源:Sender.java

示例9: connect

import se.sics.kompics.network.netty.NettyNetwork; //导入依赖的package包/类
private void connect() {
    timerComp = create(JavaTimer.class, Init.NONE);
    networkComp = create(NettyNetwork.class, new NettyInit(selfAdr));

    StreamHostComp.ExtPort extPorts = new StreamHostComp.ExtPort(timerComp.getPositive(Timer.class), networkComp.getPositive(Network.class));
    TorrentDetails torrentDetails = new TorrentDetails() {
        private final Identifier overlayId = experimentConfig.torrentId;
        private final String filePath = outputDir + File.separator + experimentConfig.torrentName;
        private final String hashPath = outputDir + File.separator + experimentConfig.torrentName + ".hash";

        @Override
        public Identifier getOverlayId() {
            return overlayId;
        }

        @Override
        public boolean download() {
            return true;
        }

        @Override
        public Torrent getTorrent() {
            throw new RuntimeException("logic error");
        }

        @Override
        public Triplet<FileMngr, HashMngr, TransferMngr> torrentMngrs(Torrent torrent) {
            try {
                int blockSize = torrent.torrentInfo.piecesPerBlock * torrent.torrentInfo.pieceSize;
                int hashSize = HashUtil.getHashSize(torrent.torrentInfo.hashAlg);

                FileMngr fileMngr = StorageMngrFactory.incompleteMMFileMngr(filePath, torrent.fileInfo.size, blockSize, torrent.torrentInfo.pieceSize);
                HashMngr hashMngr = StorageMngrFactory.incompleteMMHashMngr(hashPath, torrent.torrentInfo.hashAlg, torrent.torrentInfo.hashFileSize, hashSize);
                return Triplet.with(fileMngr, hashMngr, new TransferMngr(torrent, hashMngr, fileMngr));
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }
    };
    List<KAddress> partners = new ArrayList<KAddress>();
    partners.add(senderAdr);
    streamComp = create(StreamHostComp.class, new StreamHostComp.Init(extPorts, selfAdr, torrentDetails, partners));
    connect(streamComp.getPositive(ReportPort.class), reportPort.getPair(), Channel.TWO_WAY);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:45,代码来源:Receiver.java


注:本文中的se.sics.kompics.network.netty.NettyNetwork类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。