Package freenet.support

Examples of freenet.support.ByteArrayWrapper


        addAnnouncedIPs(addrs);
        // If it throws, we do not want to increment, so call it first.
        if(sendAnnouncement(seed)) {
          sentAnnouncements++;
          runningAnnouncements++;
          announcedToIdentities.add(new ByteArrayWrapper(seed.getPubKeyHash()));
        }
      }
      if(runningAnnouncements >= WANT_ANNOUNCEMENTS) {
        if(logMINOR)
          Logger.minor(this, "Running "+runningAnnouncements+" announcements");
View Full Code Here


    // FIXME optimise! Maybe maintain as a separate list?
    ArrayList<SeedServerPeerNode> v = new ArrayList<SeedServerPeerNode>(peers.length);
    for(PeerNode p : peers) {
      if(p instanceof SeedServerPeerNode) {
        SeedServerPeerNode sspn = (SeedServerPeerNode) p;
        if(exclude != null && exclude.contains(new ByteArrayWrapper(sspn.getIdentity()))) {
          if(logMINOR)
            Logger.minor(this, "Not including in getConnectedSeedServerPeersVector() as in exclude set: " + sspn.userToString());
          continue;
        }
        if(!sspn.isConnected()) {
View Full Code Here

   */
  @Override
  public DSAPublicKey getKey(byte[] hash, boolean canReadClientCache, boolean forULPR, BlockMetadata meta) {
    boolean ignoreOldBlocks = !node.getWriteLocalToDatastore();
    if(canReadClientCache) ignoreOldBlocks = false;
    ByteArrayWrapper w = new ByteArrayWrapper(hash);
    if (logMINOR)
      Logger.minor(this, "Getting pubkey: " + HexUtil.bytesToHex(hash));

    if (USE_RAM_PUBKEYS_CACHE) {
      synchronized (cachedPubKeys) {
View Full Code Here

   */
  @Override
  public void cacheKey(byte[] hash, DSAPublicKey key, boolean deep, boolean canWriteClientCache, boolean canWriteDatastore, boolean forULPR, boolean writeLocalToDatastore) {
    if (logMINOR)
      Logger.minor(this, "Cache key: " + HexUtil.bytesToHex(hash) + " : " + key);
    ByteArrayWrapper w = new ByteArrayWrapper(hash);
    synchronized (cachedPubKeys) {
      DSAPublicKey key2 = cachedPubKeys.get(w);
      if ((key2 != null) && !key2.equals(key))
        throw new IllegalArgumentException("Wrong hash?? Already have different key with same hash!");
      cachedPubKeys.push(w, key);
View Full Code Here

  }
 
  @Override
  public synchronized T fetch(byte[] routingKey, byte[] fullKey,
      boolean dontPromote, boolean canReadClientCache, boolean canReadSlashdotCache, boolean ignoreOldBlocks, BlockMetadata meta) throws IOException {
    ByteArrayWrapper key = new ByteArrayWrapper(routingKey);
    Block block = blocksByRoutingKey.get(key);
    if(block == null) {
      misses++;
      return null;
    }
View Full Code Here

  public synchronized void put(T block, byte[] data, byte[] header, boolean overwrite, boolean isOldBlock) throws KeyCollisionException {
    byte[] routingkey = block.getRoutingKey();
    byte[] fullKey = block.getFullKey();
   
    writes++;
    ByteArrayWrapper key = new ByteArrayWrapper(routingkey);
    Block oldBlock = blocksByRoutingKey.get(key);
    boolean storeFullKeys = callback.storeFullKeys();
    if(oldBlock != null) {
      if(callback.collisionPossible()) {
        boolean equals = Arrays.equals(oldBlock.data, data) &&
View Full Code Here

    return -1;
  }
 
  @Override
  public boolean probablyInStore(byte[] routingKey) {
    ByteArrayWrapper key = new ByteArrayWrapper(routingKey);
    return blocksByRoutingKey.get(key) != null;
  }
View Full Code Here

  }

  public void migrateTo(StoreCallback<T> target, boolean canReadClientCache) throws IOException {
    Enumeration<ByteArrayWrapper> keys = blocksByRoutingKey.keys();
    while(keys.hasMoreElements()) {
      ByteArrayWrapper routingKeyWrapped = keys.nextElement();
      byte[] routingKey = routingKeyWrapped.get();
      Block block = blocksByRoutingKey.get(routingKeyWrapped);
     
      T ret;
      try {
        ret = callback.construct(block.data, block.header, routingKey, block.fullKey, canReadClientCache, false, null, null);
View Full Code Here

  /**
   * @param meta IGNORED!
   */
  @Override
  public T fetch(byte[] routingKey, byte[] fullKey, boolean dontPromote, boolean canReadClientCache, boolean canReadSlashdotCache, boolean ignoreOldBlocks, BlockMetadata meta) throws IOException {
    ByteArrayWrapper key = new ByteArrayWrapper(routingKey);
    DiskBlock block;
    long timeAccessed;
    synchronized(this) {
      block = blocksByRoutingKey.get(key);
      if(block == null) {
View Full Code Here

    return misses;
  }

  @Override
  public boolean probablyInStore(byte[] routingKey) {
    ByteArrayWrapper key = new ByteArrayWrapper(routingKey);
    return blocksByRoutingKey.containsKey(key);
  }
View Full Code Here

TOP

Related Classes of freenet.support.ByteArrayWrapper

Copyright © 2018 www.massapicom. 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.