Examples of MutableBoolean


Examples of freenet.support.MutableBoolean

  }
 
  // Test sending it when the peer wants it to be sent. This is as a real message, *not* as a lossy message.
  public void testLoadStatsSendWhenPeerWants() throws BlockedTooLongException, InterruptedException {
    final Message loadMessage = DMT.createFNPVoid();
    final MutableBoolean gotMessage = new MutableBoolean();
    final SessionKey senderKey = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1);
    NullBasePeerNode senderNode = new NullBasePeerNode() {
     
      boolean shouldSend = true;
     
View Full Code Here

Examples of freenet.support.MutableBoolean

  }
 
  // Test sending load message as a per-packet lossy message, including message decoding.
  public void testLoadStatsHighLevel() throws BlockedTooLongException, InterruptedException {
    final Message loadMessage = DMT.createFNPVoid();
    final MutableBoolean gotMessage = new MutableBoolean();
    NullBasePeerNode senderNode = new NullBasePeerNode() {
     
      @Override
      public MessageItem makeLoadStats(boolean realtime, boolean highPriority, boolean noRemember) {
        return new MessageItem(loadMessage, null, null, (short)0);
View Full Code Here

Examples of freenet.support.MutableBoolean

   * changed.
   */
  public void extractToCache(FreenetURI key, ARCHIVE_TYPE archiveType, COMPRESSOR_TYPE ctype, final Bucket data, ArchiveContext archiveContext, ArchiveStoreContext ctx, String element, ArchiveExtractCallback callback, ClientContext context) throws ArchiveFailureException, ArchiveRestartException {
    logMINOR = Logger.shouldLog(LogLevel.MINOR, this);

    MutableBoolean gotElement = element != null ? new MutableBoolean() : null;

    if(logMINOR) Logger.minor(this, "Extracting "+key);
    ctx.removeAllCachedItems(this); // flush cache anyway
    final long expectedSize = ctx.getLastSize();
    final long archiveSize = data.size();
View Full Code Here

Examples of freenet.support.MutableBoolean

   * not to call this function if you are not going to be able to send the message:
   * check in advance if possible. */
  public synchronized MessageItem grabQueuedMessageItem(int minPriority) {
    long now = System.currentTimeMillis();
   
    MutableBoolean addPeerLoadStatsRT = new MutableBoolean();
    MutableBoolean addPeerLoadStatsBulk = new MutableBoolean();
   
    addPeerLoadStatsRT.value = true;
    addPeerLoadStatsBulk.value = true;
   
    for(int i=0;i<DMT.PRIORITY_REALTIME_DATA;i++) {
View Full Code Here

Examples of jodd.mutable.MutableBoolean

public class BigClassTest {

  @Test
  public void testAllFeatures() throws IOException, IllegalAccessException, InstantiationException {
    StatCounter.counter = 0;
    final MutableBoolean firstTime = new MutableBoolean(true);

    ProxyAspect aspect = new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
      public boolean apply(MethodInfo mi) {
        if (firstTime.value) {
          firstTime.value = false;
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

    Preconditions.checkNotNull(replicaInfo1.getReplica());
    Preconditions.checkState(replicaInfo1.getInvalidTokenException() == null);
    pair.compareWith(replicaInfo1.getReplica().getDataStream(),
                     replicaInfo1.getReplica().getMetaStream());
    replicaInfo1.getReplica().unref();
    final MutableBoolean triedToCreate = new MutableBoolean(false);
    do {
      Thread.sleep(10);
      ShortCircuitReplicaInfo replicaInfo2 =
        cache.fetchOrCreate(
          new ExtendedBlockId(123, "test_bp1"), new ShortCircuitReplicaCreator() {
          @Override
          public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() {
            triedToCreate.setValue(true);
            return null;
          }
        });
      if ((replicaInfo2 != null) && (replicaInfo2.getReplica() != null)) {
        replicaInfo2.getReplica().unref();
      }
    } while (triedToCreate.isFalse());
    cache.close();
  }
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

      Preconditions.checkState(replicaInfos[i].getInvalidTokenException() == null);
      pairs[i].compareWith(replicaInfos[i].getReplica().getDataStream(),
                           replicaInfos[i].getReplica().getMetaStream());
    }
    // The first (oldest) replica should not be cached.
    final MutableBoolean calledCreate = new MutableBoolean(false);
    replicaInfos[0] = cache.fetchOrCreate(
        new ExtendedBlockId(0, "test_bp1"),
          new ShortCircuitReplicaCreator() {
        @Override
        public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() {
          calledCreate.setValue(true);
          return null;
        }
      });
    Preconditions.checkState(replicaInfos[0].getReplica() == null);
    Assert.assertTrue(calledCreate.isTrue());
    // Clean up
    for (int i = 1; i < pairs.length; i++) {
      replicaInfos[i].getReplica().unref();
    }
    for (int i = 0; i < pairs.length; i++) {
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

        // The ClientShmManager starts off empty
        Assert.assertEquals(0,  info.size());
      }
    });
    DomainPeer peer = getDomainPeerToDn(conf);
    MutableBoolean usedPeer = new MutableBoolean(false);
    ExtendedBlockId blockId = new ExtendedBlockId(123, "xyz");
    final DatanodeInfo datanode =
        new DatanodeInfo(cluster.getDataNodes().get(0).getDatanodeId());
    // Allocating the first shm slot requires using up a peer.
    Slot slot = cache.allocShmSlot(datanode, peer, usedPeer,
                    blockId, "testAllocShm_client");
    Assert.assertNotNull(slot);
    Assert.assertTrue(usedPeer.booleanValue());
    cache.getDfsClientShmManager().visit(new Visitor() {
      @Override
      public void visit(HashMap<DatanodeInfo, PerDatanodeVisitorInfo> info)
          throws IOException {
        // The ClientShmManager starts off empty
        Assert.assertEquals(1,  info.size());
        PerDatanodeVisitorInfo vinfo = info.get(datanode);
        Assert.assertFalse(vinfo.disabled);
        Assert.assertEquals(0, vinfo.full.size());
        Assert.assertEquals(1, vinfo.notFull.size());
      }
    });
    cache.scheduleSlotReleaser(slot);
    // Wait for the slot to be released, and the shared memory area to be
    // closed.  Since we didn't register this shared memory segment on the
    // server, it will also be a test of how well the server deals with
    // bogus client behavior.
    GenericTestUtils.waitFor(new Supplier<Boolean>() {
      @Override
      public Boolean get() {
        final MutableBoolean done = new MutableBoolean(false);
        try {
          cache.getDfsClientShmManager().visit(new Visitor() {
            @Override
            public void visit(HashMap<DatanodeInfo, PerDatanodeVisitorInfo> info)
                throws IOException {
              done.setValue(info.get(datanode).full.isEmpty() &&
                  info.get(datanode).notFull.isEmpty());
            }
          });
        } catch (IOException e) {
          LOG.error("error running visitor", e);
        }
        return done.booleanValue();
      }
    }, 10, 60000);
    cluster.shutdown();
  }
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

        vals.add(new Versioned<byte[]>(key, clock1));
        vals.add(new Versioned<byte[]>(key, clock2));
        vals.add(new Versioned<byte[]>(key, clock3));
        vals.add(new Versioned<byte[]>(key, clock4));

        MutableBoolean didPrune = new MutableBoolean(false);
        List<Versioned<byte[]>> prunedVals = VersionedPutPruneJob.pruneNonReplicaEntries(vals,
                                                                                         keyReplicas,
                                                                                         didPrune);
        assertEquals("Must have pruned some versions", true, didPrune.booleanValue());
        assertEquals("Not pruned properly", TestUtils.getClock(0, 1, 2), prunedVals.get(0)
                                                                                   .getVersion());
        assertEquals("Not pruned properly", TestUtils.getClock(), prunedVals.get(1).getVersion());
        assertEquals("Not pruned properly", TestUtils.getClock(0, 1), prunedVals.get(2)
                                                                                .getVersion());
View Full Code Here

Examples of org.apache.commons.lang.mutable.MutableBoolean

        // case where key has received writes before the prune job
        List<Versioned<byte[]>> vals = new ArrayList<Versioned<byte[]>>();
        vals.add(new Versioned<byte[]>(key, fetchedClock));
        vals.add(new Versioned<byte[]>(key, onlineClock));
        MutableBoolean didPrune = new MutableBoolean();

        vals = pruneAndResolve(vals, didPrune);
        assertEquals("Must have pruned something", true, didPrune.booleanValue());
        assertEquals("Must have one winning version", 1, vals.size());
        assertEquals("Must resolve to onlineClock", onlineClock, vals.get(0).getVersion());

        // case where key has not received any writes before the prune job
        vals = new ArrayList<Versioned<byte[]>>();
        vals.add(new Versioned<byte[]>(key, fetchedClock));
        didPrune = new MutableBoolean();

        vals = pruneAndResolve(vals, didPrune);
        assertEquals("Must have pruned something", true, didPrune.booleanValue());
        assertEquals("Must have one winning version", 1, vals.size());
        assertEquals("Must resolve to [0:ts] clock",
                     TestUtils.getVersionedPutClock(now, -1, 0),
                     vals.get(0).getVersion());
        VectorClock nextOnlineClock = TestUtils.getVersionedPutClock(now + Time.MS_PER_SECOND,
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.