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


Java PeerAddress.getPeerId方法代码示例

本文整理汇总了Java中net.tomp2p.peers.PeerAddress.getPeerId方法的典型用法代码示例。如果您正苦于以下问题:Java PeerAddress.getPeerId方法的具体用法?Java PeerAddress.getPeerId怎么用?Java PeerAddress.getPeerId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.tomp2p.peers.PeerAddress的用法示例。


在下文中一共展示了PeerAddress.getPeerId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: submit

import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public FutureAsyncTask submit(final PeerAddress remotePeer, ChannelCreator channelCreator, final Number160 taskId,
        Map<Number160, Data> dataMap, Worker mapper, boolean forceUDP, boolean sign) {
    final Number320 taskKey = new Number320(taskId, remotePeer.getPeerId());
    final FutureAsyncTask futureAsyncTask = new FutureAsyncTask(remotePeer);
    futureAsyncTask.addCancellation(new Cancel() {
        @Override
        public void cancel() {
            taskFailed(taskKey);
        }
    });
    tasks.put(taskKey, futureAsyncTask);
    FutureResponse futureResponse = taskRPC.sendTask(remotePeer, channelCreator, taskId, dataMap, mapper,
            peerBean.getKeyPair(), forceUDP, sign);
    futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
        @Override
        public void operationComplete(FutureResponse future) throws Exception {
            if (future.isSuccess()) {
                // keep track of it and poll to see if its still alive
                scheduler.keepTrack(remotePeer, taskId, (TaskResultListener) AsyncTask.this);
            } else {
                futureAsyncTask.setFailed(future);
            }
        }
    });
    return futureAsyncTask;
}
 
开发者ID:maxatp,项目名称:tomp2p_5,代码行数:27,代码来源:AsyncTask.java

示例2: putReferred

import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public boolean putReferred(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress,
        PeerAddress referrer, Data attachement, ReferrerType type) {
    Number160 peerId = peerAddress.getPeerId();
    // we cannot do public key check, because these data is referenced from
    // other peers and we don't know about the timeouts as well
    // store the data
    if (canStoreSecondary(locationKey, domainKey)) {
        // maybe we have space in our secondary tracker, store them there!
        Number320 key = new Number320(locationKey, domainKey);
        if (storeData(peerAddress, attachement, peerId, key, trackerDataSecondary,
                reverseTrackerDataSecondary, getSecondaryFactor())) {
            if (ReferrerType.MESH == type) {
                if (!isSecondaryTracker(locationKey, domainKey)) {
                    maintenance
                            .addTrackerMaintenance(peerAddress, referrer, locationKey, domainKey, this);
                }
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:maxatp,项目名称:tomp2p_5,代码行数:23,代码来源:TrackerStorage.java

示例3: routing

import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public static void routing(Number160 key, Peer[] peers, int start) {
    System.out.println("routing: searching for key " + key);
    NavigableSet<PeerAddress> pa1 = new TreeSet<PeerAddress>(PeerMap.createComparator(key));
    NavigableSet<PeerAddress> queried = new TreeSet<PeerAddress>(PeerMap.createComparator(key));
    Number160 result = Number160.ZERO;
    Number160 resultPeer = new Number160("0xd75d1a3d57841fbc9e2a3d175d6a35dc2e15b9f");
    int round = 0;
    while (!resultPeer.equals(result)) {
        System.out.println("round " + round);
        round++;
        pa1.addAll(peers[start].getPeerBean().peerMap().getAll());
        queried.add(peers[start].getPeerAddress());
        System.out.println("closest so far: " + queried.first());
        PeerAddress next = pa1.pollFirst();
        while (queried.contains(next)) {
            next = pa1.pollFirst();
        }
        result = next.getPeerId();
        start = findNr(next.getPeerId().toString(), peers);
    }
}
 
开发者ID:maxatp,项目名称:tomp2p_5,代码行数:22,代码来源:Utils2.java

示例4: put

import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public boolean put(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress,
        PublicKey publicKey, Data attachement) {
    if (logger.isDebugEnabled()) {
        logger.debug("try to store on tracker " + locationKey);
    }
    Number160 peerId = peerAddress.getPeerId();
    // check if this guy is offline
    if (isOffline(peerAddress)) {
        return false;
    }
    // check identity
    if (!identityManagement.checkIdentity(peerId, publicKey)) {
        return false;
    }

    // store the data
    if (canStorePrimary(locationKey, domainKey, false)) {
        // we have space in our primary tracker, store them there!
        Number320 key = new Number320(locationKey, domainKey);
        if (storeData(peerAddress, attachement, peerId, key, trackerDataMesh, reverseTrackerDataMesh,
                getPrimanyFactor())) {
            if (replication != null) {
                replication.updateAndNotifyResponsibilities(locationKey);
            }
            return true;
        }
    }
    // do not store in the secondary map, since this is used for PEX, for
    // unknown peers.
    return false;
}
 
开发者ID:maxatp,项目名称:tomp2p_5,代码行数:32,代码来源:TrackerStorage.java


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