Ejemplo n.º 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);
 }
Ejemplo n.º 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.");
 }
Ejemplo n.º 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();
    }
  }
Ejemplo n.º 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();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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()]);
 }
Ejemplo n.º 7
0
 public List<BlockTargetPair> getReplicationCommand(int maxTransfers) {
   return replicateBlocks.poll(maxTransfers);
 }
Ejemplo n.º 8
0
 /** The number of work items that are pending to be replicated */
 int getNumberOfBlocksToBeReplicated() {
   return PendingReplicationWithoutTargets + replicateBlocks.size();
 }
Ejemplo n.º 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));
 }