Examples of Number160


Examples of net.tomp2p.peers.Number160

   * Get all triples stored at given key (as Collection)
   * @param locationKey key
   * @return all triples stored at this key
   */
  public Collection<Triple> getTriples(String locationKey) {
    Number160 k = Number160.createHash(locationKey);
    Map<Number480, Data> all = p2pStorage.subMap(k);
    List<Triple> tmp = new LinkedList<Triple>();
    for (Data d : all.values()) {
      try {
        if (d.getObject() instanceof Triple) {
View Full Code Here

Examples of net.tomp2p.peers.Number160

   * Get all triples stored at given key (as List)
   * @param locationKey key
   * @return all triples stored at this key
   */
  private List<Triple> getTriple(String key) {
    Number160 locationKey = Number160.createHash(key);
    ;
    List<Triple> result = new ArrayList<Triple>();

    Map<Number480, Data> all = p2pStorage.subMap(locationKey);
    l.log("GET", String.format("GOT %d items in %s (%s)", all.values()
View Full Code Here

Examples of net.tomp2p.peers.Number160

    TomP2P_Peer p = new TomP2P_Peer();

    Random r = new Random();
    final Peer peer;
    try {
      peer = new PeerMaker(new Number160(r)).setPorts(port)
          .makeAndListen();

      PeerAddress pa = new PeerAddress(Number160.ZERO, masterPeerAddress,
          masterPeerPort, masterPeerPort);
      logger.info(String.format("Client-Node connecting to master: %s",
View Full Code Here

Examples of net.tomp2p.peers.Number160

    Random r = new Random();
    final Peer peer;
    try {

      if (masterPeer != null) {
        peer = new PeerMaker(new Number160(r)).setPorts(port)
            .makeAndListen();
        FutureBootstrap res = peer.bootstrap()
            .setPeerAddress(masterPeer.getPeerAddress()).start();
        res.awaitUninterruptibly();

      } else
        peer = new PeerMaker(new Number160(r)).setPorts(port)
            .makeAndListen();

      // Only if using the internet:
      // peer.getConfiguration().setBehindFirewall(true);
    } catch (java.net.BindException
View Full Code Here

Examples of net.tomp2p.peers.Number160

  @SuppressWarnings("unchecked")
  @Override
  public List<Triple> get(String locationKey) {
    l.log(TYPE_RETRIEVE,
        String.format("Peer %s: get keys: %s", p, locationKey), 10);
    final Number160 hash = Number160.createHash(locationKey);
    FutureDHT request;
    try {
      request = p.get(hash).setRequestP2PConfiguration(reqParam).setAll()
          .start();
      request.awaitUninterruptibly();
View Full Code Here

Examples of net.tomp2p.peers.Number160

    return (path.delete());
  }

  @Override
  public void remove(String locationKey, Triple item) {
    final Number160 hash = Number160.createHash(locationKey);
    FutureDHT request;
    l.log(TYPE_REMOVE, String.format("Peer %s: remove item %s in key: %s",
        p, item, locationKey), 10);
    final Number160 contentKey = Number160.createHash(item.toString());
    request = p.remove(hash).setContentKey(contentKey)
        .setReturnResults(false).start();
    request.awaitUninterruptibly();
    logger.debug(String.format("Remove triple in key %s (%s)", locationKey,
        hash));
View Full Code Here

Examples of net.tomp2p.peers.Number160

        hash));
  }

  @Override
  public void removeAll(String locationKey, Triple... item) {
    final Number160 hash = Number160.createHash(locationKey);
    FutureDHT request;
    Set<Number160> contentKeys = new HashSet<Number160>();
    for (Triple t : item) {
      final Number160 contentKey = Number160.createHash(t.toString());
      contentKeys.add(contentKey);
    }
    l.log(TYPE_REMOVE, String.format(
        "Peer %s: removed %d  item in key: %s", p, contentKeys.size(),
        locationKey), 10);
View Full Code Here

Examples of net.tomp2p.peers.Number160

  @Override
  public void add(String locationKey, Triple t) {
    l.log(TYPE_ADD, String.format("Peer %s: add item %s in key: %s", p, t,
        locationKey), 10);
    final Number160 hash = Number160.createHash(locationKey);
    final Number160 contentKey = Number160.createHash(t.toString());
    FutureDHT request;
    try {
      Data valueToAdd;
      if (usingDebugObject)
        valueToAdd = new Data(new TomP2P_Item<Triple>(locationKey, t));
View Full Code Here

Examples of net.tomp2p.peers.Number160

    }
  }

  @Override
  public void addAll(String locationKey, Triple... values) {
    final Number160 hash = Number160.createHash(locationKey);
    Map<Number160, Data> map = new HashMap<Number160, Data>();
    for (Triple t : values) {
      Data valueToAdd = null;
      final Number160 contentKey = Number160.createHash(t.toString());
      try {
        if (usingDebugObject)
          valueToAdd = new Data(new TomP2P_Item<Triple>(locationKey,
              t));
        else
View Full Code Here

Examples of net.tomp2p.peers.Number160

  Not used anoymore, only for debugging, because other information
  can be stored with the Triple, such as the key
  */
  @Deprecated
  public void old_addAll(String locationKey, Triple... values) {
    final Number160 hash = Number160.createHash(locationKey);
    Set<Data> list = new HashSet<Data>();
    for (Triple t : values) {
      Data valueToAdd = null;
      try {
        if (usingDebugObject)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.