コード例 #1
0
 /** Store block recovery work. */
 void addBlockToBeRecovered(BlockInfoUnderConstruction block) {
   if (recoverBlocks.contains(block)) {
     // this prevents adding the same block twice to the recovery queue
     BlockManager.LOG.info(block + " is already in the recovery queue");
     return;
   }
   recoverBlocks.offer(block);
 }
コード例 #2
0
 @Override
 public void onDisable() {
   log.info("Shutting down blockqueue and undothread, please wait.");
   bq.shouldrun = false;
   while (bq.isAlive()) {
     // wait
   }
   ut.shouldRun = false;
   while (ut.isAlive()) {
     // wait
   }
   log.info("WorldThreadit Disabled.");
 }
コード例 #3
0
  @Test
  public void remove() {
    Thread t1 =
        new Thread(
            new Runnable() {

              @Override
              public void run() {
                try {
                  Thread.sleep(2000);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }

                int i = 5;
                while (i > 0) {
                  bq.add(new Object());
                  i--;
                }
              }
            });
    t1.start();

    bq.remove();

    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
コード例 #4
0
 @Override
 public String dumpDatanode() {
   StringBuilder sb = new StringBuilder(super.dumpDatanode());
   int repl = replicateBlocks.size();
   if (repl > 0) {
     sb.append(" ").append(repl).append(" blocks to be replicated;");
   }
   int inval = invalidateBlocks.size();
   if (inval > 0) {
     sb.append(" ").append(inval).append(" blocks to be invalidated;");
   }
   int recover = recoverBlocks.size();
   if (recover > 0) {
     sb.append(" ").append(recover).append(" blocks to be recovered;");
   }
   return sb.toString();
 }
コード例 #5
0
 @Override
 public void onEnable() {
   WorldThreadit.plugin = this;
   log = getLogger();
   getServer().getPluginManager().registerEvents(new WorldThreadit(), this);
   bq = new BlockQueue(this);
   bq.start();
   ut = new UndoThread(this);
   ut.start();
   log.info("WorldThreadit enabled!");
   getCommand("wt").setExecutor(new BaseCommandExecutor(this));
 }
コード例 #6
0
 public BlockInfoUnderConstruction[] getLeaseRecoveryCommand(int maxTransfers) {
   List<BlockInfoUnderConstruction> blocks = recoverBlocks.poll(maxTransfers);
   if (blocks == null) return null;
   return blocks.toArray(new BlockInfoUnderConstruction[blocks.size()]);
 }
コード例 #7
0
 public List<BlockTargetPair> getReplicationCommand(int maxTransfers) {
   return replicateBlocks.poll(maxTransfers);
 }
コード例 #8
0
 /** The number of work items that are pending to be replicated */
 int getNumberOfBlocksToBeReplicated() {
   return PendingReplicationWithoutTargets + replicateBlocks.size();
 }
コード例 #9
0
 /** Store block replication work. */
 void addBlockToBeReplicated(Block block, DatanodeStorageInfo[] targets) {
   assert (block != null && targets != null && targets.length > 0);
   replicateBlocks.offer(new BlockTargetPair(block, targets));
 }