当前位置: 首页>>代码示例>>Java>>正文


Java MonitoredTask.cleanup方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.monitoring.MonitoredTask.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Java MonitoredTask.cleanup方法的具体用法?Java MonitoredTask.cleanup怎么用?Java MonitoredTask.cleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.monitoring.MonitoredTask的用法示例。


在下文中一共展示了MonitoredTask.cleanup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: close

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Close down this HRegion. Flush the cache unless abort parameter is true, Shut down each HStore,
 * don't service any more calls. This method could take some time to execute, so don't call it
 * from a time-sensitive thread.
 *
 * @param abort true if server is aborting (only during testing)
 * @return Vector of all the storage files that the HRegion's component HStores make use of. It's
 * a list of HStoreFile objects. Can be null if we are not to close at this time or we are
 * already closed.
 * @throws IOException              e
 * @throws DroppedSnapshotException Thrown when replay of wal is required because a Snapshot was
 *                                  not properly persisted. The region is put in closing mode, and the caller MUST abort
 *                                  after this.
 */
public Map<byte[], List<StoreFile>> close(final boolean abort) throws IOException {
  // Only allow one thread to close at a time. Serialize them so dual
  // threads attempting to close will run up against each other.
  MonitoredTask status =
      TaskMonitor.get().createStatus("Closing region " + this + (abort ? " due to abort" : ""));

  status.setStatus("Waiting for close lock");
  try {
    synchronized (closeLock) {
      return doClose(abort, status);
    }
  } finally {
    status.cleanup();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:HRegion.java

示例2: close

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Close down this HRegion. Flush the cache unless abort parameter is true, Shut down each HStore,
 * don't service any more calls. This method could take some time to execute, so don't call it
 * from a time-sensitive thread.
 * @param abort true if server is aborting (only during testing)
 * @return Vector of all the storage files that the HRegion's component HStores make use of. It's
 *         a list of HStoreFile objects. Can be null if we are not to close at this time or we are
 *         already closed.
 * @throws IOException e
 */
public List<StoreFile> close(final boolean abort) throws IOException {
  // Only allow one thread to close at a time. Serialize them so dual
  // threads attempting to close will run up against each other.
  MonitoredTask status =
      TaskMonitor.get().createStatus("Closing region " + this + (abort ? " due to abort" : ""));

  status.setStatus("Waiting for close lock");
  try {
    synchronized (closeLock) {
      return doClose(abort, status);
    }
  } finally {
    status.cleanup();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:HRegion.java

示例3: close

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Close down this HRegion.  Flush the cache unless abort parameter is true,
 * Shut down each HStore, don't service any more calls.
 * <p/>
 * This method could take some time to execute, so don't call it from a
 * time-sensitive thread.
 *
 * @param abort true if server is aborting (only during testing)
 * @return Vector of all the storage files that the HRegion's component
 * HStores make use of.  It's a list of HStoreFile objects.  Can be null if
 * we are not to close at this time or we are already closed.
 * @throws IOException e
 */
public Map<byte[], List<StoreFile>> close(final boolean abort) throws IOException {
    // Only allow one thread to close at a time. Serialize them so dual
    // threads attempting to close will run up against each other.
    MonitoredTask status = TaskMonitor.get().createStatus(
            "Closing region " + this +
                    (abort ? " due to abort" : ""));

    status.setStatus("Waiting for close lock");
    try {
        synchronized (closeLock) {
            return doClose(abort, status);
        }
    } finally {
        status.cleanup();
    }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:30,代码来源:HRegion.java

示例4: close

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Close down this HRegion.  Flush the cache unless abort parameter is true,
 * Shut down each HStore, don't service any more calls.
 *
 * This method could take some time to execute, so don't call it from a
 * time-sensitive thread.
 *
 * @param abort true if server is aborting (only during testing)
 * @return Vector of all the storage files that the HRegion's component
 * HStores make use of.  It's a list of HStoreFile objects.  Can be null if
 * we are not to close at this time or we are already closed.
 *
 * @throws IOException e
 */
public Map<byte[], List<StoreFile>> close(final boolean abort) throws IOException {
  // Only allow one thread to close at a time. Serialize them so dual
  // threads attempting to close will run up against each other.
  MonitoredTask status = TaskMonitor.get().createStatus(
      "Closing region " + this +
      (abort ? " due to abort" : ""));

  status.setStatus("Waiting for close lock");
  try {
    synchronized (closeLock) {
      return doClose(abort, status);
    }
  } finally {
    status.cleanup();
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:31,代码来源:HRegion.java

示例5: close

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Close down this HRegion.  Flush the cache unless abort parameter is true,
 * Shut down each HStore, don't service any more calls.
 *
 * This method could take some time to execute, so don't call it from a
 * time-sensitive thread.
 *
 * @param abort true if server is aborting (only during testing)
 * @return Vector of all the storage files that the HRegion's component
 * HStores make use of.  It's a list of HStoreFile objects.  Can be null if
 * we are not to close at this time or we are already closed.
 *
 * @throws IOException e
 */
public List<StoreFile> close(final boolean abort) throws IOException {
  // Only allow one thread to close at a time. Serialize them so dual
  // threads attempting to close will run up against each other.
  MonitoredTask status = TaskMonitor.get().createStatus(
      "Closing region " + this +
      (abort ? " due to abort" : ""));

  status.setStatus("Waiting for close lock");
  try {
    synchronized (closeLock) {
      return doClose(abort, status);
    }
  } finally {
    status.cleanup();
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:31,代码来源:HRegion.java

示例6: setRecovering

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Reset recovering state of current region
 */
public void setRecovering(boolean newState) {
  boolean wasRecovering = this.recovering;
  // before we flip the recovering switch (enabling reads) we should write the
  // region open
  // event to WAL if needed
  if (wal != null && getRegionServerServices() != null && !writestate.readOnly && wasRecovering
      && !newState) {

    // force a flush only if region replication is set up for this region.
    // Otherwise no need.
    boolean forceFlush = getTableDesc().getRegionReplication() > 1;

    MonitoredTask status = TaskMonitor.get().createStatus("Recovering region " + this);

    try {
      // force a flush first
      if (forceFlush) {
        status.setStatus("Flushing region " + this + " because recovery is finished");
        internalFlushcache(status);
      }

      status.setStatus("Writing region open event marker to WAL because recovery is finished");
      try {
        long seqId = openSeqNum;
        // obtain a new seqId because we possibly have writes and flushes on
        // top of openSeqNum
        if (wal != null) {
          seqId = getNextSequenceId(wal);
        }
        writeRegionOpenMarker(wal, seqId);
      } catch (IOException e) {
        // We cannot rethrow this exception since we are being called from the
        // zk thread. The
        // region has already opened. In this case we log the error, but
        // continue
        LOG.warn(getRegionInfo().getEncodedName() + " : was not able to write region opening "
            + "event to WAL, continuing", e);
      }
    } catch (IOException ioe) {
      // Distributed log replay semantics does not necessarily require a
      // flush, since the replayed
      // data is already written again in the WAL. So failed flush should be
      // fine.
      LOG.warn(getRegionInfo().getEncodedName() + " : was not able to flush "
          + "event to WAL, continuing", ioe);
    } finally {
      status.cleanup();
    }
  }

  this.recovering = newState;
  if (wasRecovering && !recovering) {
    // Call only when wal replay is over.
    coprocessorHost.postLogReplay();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:60,代码来源:HRegion.java

示例7: run

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Main processing loop for the HMaster.
 * <ol>
 * <li>Block until becoming active master
 * <li>Finish initialization via finishInitialization(MonitoredTask)
 * <li>Enter loop until we are stopped
 * <li>Stop services and perform cleanup once stopped
 * </ol>
 */
@Override
public void run() {
  MonitoredTask startupStatus =
    TaskMonitor.get().createStatus("Master startup");
  startupStatus.setDescription("Master startup");
  masterStartTime = System.currentTimeMillis();
  try {
    this.registeredZKListenersBeforeRecovery = this.zooKeeper.getListeners();

    // Put up info server.
    int port = this.conf.getInt("hbase.master.info.port", 60010);
    if (port >= 0) {
      String a = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
      this.infoServer = new InfoServer(MASTER, a, port, false, this.conf);
      this.infoServer.addServlet("status", "/master-status", MasterStatusServlet.class);
      this.infoServer.addServlet("dump", "/dump", MasterDumpServlet.class);
      this.infoServer.setAttribute(MASTER, this);
      this.infoServer.start();
    }

    /*
     * Block on becoming the active master.
     *
     * We race with other masters to write our address into ZooKeeper.  If we
     * succeed, we are the primary/active master and finish initialization.
     *
     * If we do not succeed, there is another active master and we should
     * now wait until it dies to try and become the next active master.  If we
     * do not succeed on our first attempt, this is no longer a cluster startup.
     */
    becomeActiveMaster(startupStatus);

    // We are either the active master or we were asked to shutdown
    if (!this.stopped) {
      finishInitialization(startupStatus, false);
      loop();
    }
  } catch (Throwable t) {
    // HBASE-5680: Likely hadoop23 vs hadoop 20.x/1.x incompatibility
    if (t instanceof NoClassDefFoundError &&
        t.getMessage().contains("org/apache/hadoop/hdfs/protocol/FSConstants$SafeModeAction")) {
        // improved error message for this special case
        abort("HBase is having a problem with its Hadoop jars.  You may need to "
            + "recompile HBase against Hadoop version "
            +  org.apache.hadoop.util.VersionInfo.getVersion()
            + " or change your hadoop jars to start properly", t);
    } else {
      abort("Unhandled exception. Starting shutdown.", t);
    }
  } finally {
    startupStatus.cleanup();

    stopChores();
    // Wait for all the remaining region servers to report in IFF we were
    // running a cluster shutdown AND we were NOT aborting.
    if (!this.abort && this.serverManager != null &&
        this.serverManager.isClusterShutdown()) {
      this.serverManager.letRegionServersShutdown();
    }
    stopServiceThreads();
    // Stop services started for both backup and active masters
    if (this.activeMasterManager != null) this.activeMasterManager.stop();
    if (this.catalogTracker != null) this.catalogTracker.stop();
    if (this.serverManager != null) this.serverManager.stop();
    if (this.assignmentManager != null) this.assignmentManager.stop();
    if (this.fileSystemManager != null) this.fileSystemManager.stop();
    if (this.snapshotManager != null) this.snapshotManager.stop("server shutting down.");
    this.zooKeeper.close();
  }
  LOG.info("HMaster main thread exiting");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:81,代码来源:HMaster.java

示例8: tryRecoveringExpiredZKSession

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * We do the following in a different thread.  If it is not completed
 * in time, we will time it out and assume it is not easy to recover.
 *
 * 1. Create a new ZK session. (since our current one is expired)
 * 2. Try to become a primary master again
 * 3. Initialize all ZK based system trackers.
 * 4. Assign root and meta. (they are already assigned, but we need to update our
 * internal memory state to reflect it)
 * 5. Process any RIT if any during the process of our recovery.
 *
 * @return True if we could successfully recover from ZK session expiry.
 * @throws InterruptedException
 * @throws IOException
 * @throws KeeperException
 * @throws ExecutionException
 */
private boolean tryRecoveringExpiredZKSession() throws InterruptedException,
    IOException, KeeperException, ExecutionException {

  this.zooKeeper.unregisterAllListeners();
  // add back listeners which were registered before master initialization
  // because they won't be added back in below Master re-initialization code
  if (this.registeredZKListenersBeforeRecovery != null) {
    for (ZooKeeperListener curListener : this.registeredZKListenersBeforeRecovery) {
      this.zooKeeper.registerListener(curListener);
    }
  }

  this.zooKeeper.reconnectAfterExpiration();

  Callable<Boolean> callable = new Callable<Boolean> () {
    public Boolean call() throws InterruptedException,
        IOException, KeeperException {
      MonitoredTask status =
        TaskMonitor.get().createStatus("Recovering expired ZK session");
      try {
        if (!becomeActiveMaster(status)) {
          return Boolean.FALSE;
        }
        serverManager.disableSSHForRoot();
        serverShutdownHandlerEnabled = false;
        initialized = false;
        finishInitialization(status, true);
        return Boolean.TRUE;
      } finally {
        status.cleanup();
      }
    }
  };

  long timeout =
    conf.getLong("hbase.master.zksession.recover.timeout", 300000);
  java.util.concurrent.ExecutorService executor =
    Executors.newSingleThreadExecutor();
  Future<Boolean> result = executor.submit(callable);
  executor.shutdown();
  if (executor.awaitTermination(timeout, TimeUnit.MILLISECONDS)
      && result.isDone()) {
    Boolean recovered = result.get();
    if (recovered != null) {
      return recovered.booleanValue();
    }
  }
  executor.shutdownNow();
  return false;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:68,代码来源:HMaster.java

示例9: flushcache

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Flush the cache. When this method is called the cache will be flushed unless:
 * <ol>
 * <li>the cache is empty</li>
 * <li>the region is closed.</li>
 * <li>a flush is already in progress</li>
 * <li>writes are disabled</li>
 * </ol>
 * <p>
 * This method may block for some time, so it should not be called from a time-sensitive thread.
 * @return true if the region needs compaction
 * @throws IOException general io exceptions
 * @throws DroppedSnapshotException Thrown when replay of hlog is required because a Snapshot was
 *           not properly persisted.
 */
public boolean flushcache() throws IOException {
  // fail-fast instead of waiting on the lock
  if (this.closing.get()) {
    LOG.debug("Skipping flush on " + this + " because closing");
    return false;
  }
  MonitoredTask status = TaskMonitor.get().createStatus("Flushing " + this);
  status.setStatus("Acquiring readlock on region");
  // block waiting for the lock for flushing cache
  lock.readLock().lock();
  try {
    if (this.closed.get()) {
      LOG.debug("Skipping flush on " + this + " because closed");
      status.abort("Skipped: closed");
      return false;
    }
    if (coprocessorHost != null) {
      status.setStatus("Running coprocessor pre-flush hooks");
      coprocessorHost.preFlush();
    }
    if (numPutsWithoutWAL.get() > 0) {
      numPutsWithoutWAL.set(0);
      dataInMemoryWithoutWAL.set(0);
    }
    synchronized (writestate) {
      if (!writestate.flushing && writestate.writesEnabled) {
        this.writestate.flushing = true;
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("NOT flushing memstore for region " + this + ", flushing="
              + writestate.flushing + ", writesEnabled=" + writestate.writesEnabled);
        }
        status.abort("Not flushing since "
            + (writestate.flushing ? "already flushing" : "writes not enabled"));
        return false;
      }
    }
    try {
      boolean result = internalFlushcache(status);

      if (coprocessorHost != null) {
        status.setStatus("Running post-flush coprocessor hooks");
        coprocessorHost.postFlush();
      }

      status.markComplete("Flush successful");
      return result;
    } finally {
      synchronized (writestate) {
        writestate.flushing = false;
        this.writestate.flushRequested = false;
        writestate.notifyAll();
      }
    }
  } finally {
    lock.readLock().unlock();
    status.cleanup();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:75,代码来源:HRegion.java

示例10: tryRecoveringExpiredZKSession

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * We do the following in a different thread.  If it is not completed
 * in time, we will time it out and assume it is not easy to recover.
 *
 * 1. Create a new ZK session. (since our current one is expired)
 * 2. Try to become a primary master again
 * 3. Initialize all ZK based system trackers.
 * 4. Assign meta. (they are already assigned, but we need to update our
 * internal memory state to reflect it)
 * 5. Process any RIT if any during the process of our recovery.
 *
 * @return True if we could successfully recover from ZK session expiry.
 * @throws InterruptedException
 * @throws IOException
 * @throws KeeperException
 * @throws ExecutionException
 */
private boolean tryRecoveringExpiredZKSession() throws InterruptedException,
    IOException, KeeperException, ExecutionException {

  this.zooKeeper.unregisterAllListeners();
  // add back listeners which were registered before master initialization
  // because they won't be added back in below Master re-initialization code
  if (this.registeredZKListenersBeforeRecovery != null) {
    for (ZooKeeperListener curListener : this.registeredZKListenersBeforeRecovery) {
      this.zooKeeper.registerListener(curListener);
    }
  }

  this.zooKeeper.reconnectAfterExpiration();

  Callable<Boolean> callable = new Callable<Boolean> () {
    @Override
    public Boolean call() throws InterruptedException,
        IOException, KeeperException {
      MonitoredTask status =
        TaskMonitor.get().createStatus("Recovering expired ZK session");
      try {
        if (!becomeActiveMaster(status)) {
          return Boolean.FALSE;
        }
        serverShutdownHandlerEnabled = false;
        initialized = false;
        finishInitialization(status, true);
        return !stopped;
      } finally {
        status.cleanup();
      }
    }
  };

  long timeout =
    conf.getLong("hbase.master.zksession.recover.timeout", 300000);
  java.util.concurrent.ExecutorService executor =
    Executors.newSingleThreadExecutor();
  Future<Boolean> result = executor.submit(callable);
  executor.shutdown();
  if (executor.awaitTermination(timeout, TimeUnit.MILLISECONDS)
      && result.isDone()) {
    Boolean recovered = result.get();
    if (recovered != null) {
      return recovered.booleanValue();
    }
  }
  executor.shutdownNow();
  return false;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:68,代码来源:HMaster.java

示例11: flushcache

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Flush the cache.
 *
 * When this method is called the cache will be flushed unless:
 * <ol>
 *   <li>the cache is empty</li>
 *   <li>the region is closed.</li>
 *   <li>a flush is already in progress</li>
 *   <li>writes are disabled</li>
 * </ol>
 *
 * <p>This method may block for some time, so it should not be called from a
 * time-sensitive thread.
 *
 * @return true if the region needs compaction
 *
 * @throws IOException general io exceptions
 * @throws DroppedSnapshotException Thrown when replay of hlog is required
 * because a Snapshot was not properly persisted.
 */
public boolean flushcache() throws IOException {
  // fail-fast instead of waiting on the lock
  if (this.closing.get()) {
    LOG.debug("Skipping flush on " + this + " because closing");
    return false;
  }
  MonitoredTask status = TaskMonitor.get().createStatus("Flushing " + this);
  status.setStatus("Acquiring readlock on region");
  // block waiting for the lock for flushing cache
  lock.readLock().lock();
  try {
    if (this.closed.get()) {
      LOG.debug("Skipping flush on " + this + " because closed");
      status.abort("Skipped: closed");
      return false;
    }
    if (coprocessorHost != null) {
      status.setStatus("Running coprocessor pre-flush hooks");
      coprocessorHost.preFlush();
    }
    if (numPutsWithoutWAL.get() > 0) {
      numPutsWithoutWAL.set(0);
      dataInMemoryWithoutWAL.set(0);
    }
    synchronized (writestate) {
      if (!writestate.flushing && writestate.writesEnabled) {
        this.writestate.flushing = true;
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("NOT flushing memstore for region " + this
              + ", flushing=" + writestate.flushing + ", writesEnabled="
              + writestate.writesEnabled);
        }
        status.abort("Not flushing since "
            + (writestate.flushing ? "already flushing"
                : "writes not enabled"));
        return false;
      }
    }
    try {
      boolean result = internalFlushcache(status);

      if (coprocessorHost != null) {
        status.setStatus("Running post-flush coprocessor hooks");
        coprocessorHost.postFlush();
      }

      status.markComplete("Flush successful");
      return result;
    } finally {
      synchronized (writestate) {
        writestate.flushing = false;
        this.writestate.flushRequested = false;
        writestate.notifyAll();
      }
    }
  } finally {
    lock.readLock().unlock();
    status.cleanup();
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:82,代码来源:HRegion.java

示例12: startActiveMasterManager

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
private void startActiveMasterManager(int infoPort) throws KeeperException {
  String backupZNode = ZNodePaths.joinZNode(
    zooKeeper.znodePaths.backupMasterAddressesZNode, serverName.toString());
  /*
  * Add a ZNode for ourselves in the backup master directory since we
  * may not become the active master. If so, we want the actual active
  * master to know we are backup masters, so that it won't assign
  * regions to us if so configured.
  *
  * If we become the active master later, ActiveMasterManager will delete
  * this node explicitly.  If we crash before then, ZooKeeper will delete
  * this node for us since it is ephemeral.
  */
  LOG.info("Adding backup master ZNode " + backupZNode);
  if (!MasterAddressTracker.setMasterAddress(zooKeeper, backupZNode, serverName, infoPort)) {
    LOG.warn("Failed create of " + backupZNode + " by " + serverName);
  }
  this.activeMasterManager.setInfoPort(infoPort);
  int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
  // If we're a backup master, stall until a primary to write this address
  if (conf.getBoolean(HConstants.MASTER_TYPE_BACKUP, HConstants.DEFAULT_MASTER_TYPE_BACKUP)) {
    LOG.debug("HMaster started in backup mode. Stalling until master znode is written.");
    // This will only be a minute or so while the cluster starts up,
    // so don't worry about setting watches on the parent znode
    while (!activeMasterManager.hasActiveMaster()) {
      LOG.debug("Waiting for master address and cluster state znode to be written.");
      Threads.sleep(timeout);
    }
  }
  MonitoredTask status = TaskMonitor.get().createStatus("Master startup");
  status.setDescription("Master startup");
  try {
    if (activeMasterManager.blockUntilBecomingActiveMaster(timeout, status)) {
      finishActiveMasterInitialization(status);
    }
  } catch (Throwable t) {
    status.setStatus("Failed to become active: " + t.getMessage());
    LOG.error(HBaseMarkers.FATAL, "Failed to become active master", t);
    // HBASE-5680: Likely hadoop23 vs hadoop 20.x/1.x incompatibility
    if (t instanceof NoClassDefFoundError && t.getMessage().
        contains("org/apache/hadoop/hdfs/protocol/HdfsConstants$SafeModeAction")) {
      // improved error message for this special case
      abort("HBase is having a problem with its Hadoop jars.  You may need to recompile " +
        "HBase against Hadoop version " + org.apache.hadoop.util.VersionInfo.getVersion() +
        " or change your hadoop jars to start properly", t);
    } else {
      abort("Unhandled exception. Starting shutdown.", t);
    }
  } finally {
    status.cleanup();
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:53,代码来源:HMaster.java

示例13: close

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Close down this HRegion.  Flush the cache unless abort parameter is true,
 * Shut down each HStore, don't service any more calls.
 *
 * This method could take some time to execute, so don't call it from a
 * time-sensitive thread.
 *
 * @param abort true if server is aborting (only during testing)
 * @return Vector of all the storage files that the HRegion's component
 * HStores make use of.  It's a list of StoreFile objects.  Can be null if
 * we are not to close at this time or we are already closed.
 *
 * @throws IOException e
 * @throws DroppedSnapshotException Thrown when replay of wal is required
 * because a Snapshot was not properly persisted. The region is put in closing mode, and the
 * caller MUST abort after this.
 */
public Map<byte[], List<HStoreFile>> close(boolean abort) throws IOException {
  // Only allow one thread to close at a time. Serialize them so dual
  // threads attempting to close will run up against each other.
  MonitoredTask status = TaskMonitor.get().createStatus(
      "Closing region " + this +
      (abort ? " due to abort" : ""));

  status.setStatus("Waiting for close lock");
  try {
    synchronized (closeLock) {
      return doClose(abort, status);
    }
  } finally {
    status.cleanup();
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:HRegion.java

示例14: run

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * Main processing loop for the HMaster.
 * <ol>
 * <li>Block until becoming active master
 * <li>Finish initialization via finishInitialization(MonitoredTask)
 * <li>Enter loop until we are stopped
 * <li>Stop services and perform cleanup once stopped
 * </ol>
 */
@Override
public void run() {
  MonitoredTask startupStatus =
    TaskMonitor.get().createStatus("Master startup");
  startupStatus.setDescription("Master startup");
  masterStartTime = System.currentTimeMillis();
  try {
    /*
     * Block on becoming the active master.
     *
     * We race with other masters to write our address into ZooKeeper.  If we
     * succeed, we are the primary/active master and finish initialization.
     *
     * If we do not succeed, there is another active master and we should
     * now wait until it dies to try and become the next active master.  If we
     * do not succeed on our first attempt, this is no longer a cluster startup.
     */
    becomeActiveMaster(startupStatus);

    // We are either the active master or we were asked to shutdown
    if (!this.stopped) {
      finishInitialization(startupStatus);
      loop();
    }
  } catch (Throwable t) {
    abort("Unhandled exception. Starting shutdown.", t);
  } finally {
    startupStatus.cleanup();
    
    stopChores();
    // Wait for all the remaining region servers to report in IFF we were
    // running a cluster shutdown AND we were NOT aborting.
    if (!this.abort && this.serverManager != null &&
        this.serverManager.isClusterShutdown()) {
      this.serverManager.letRegionServersShutdown();
    }
    stopServiceThreads();
    // Stop services started for both backup and active masters
    if (this.activeMasterManager != null) this.activeMasterManager.stop();
    if (this.catalogTracker != null) this.catalogTracker.stop();
    if (this.serverManager != null) this.serverManager.stop();
    if (this.assignmentManager != null) this.assignmentManager.stop();
    if (this.fileSystemManager != null) this.fileSystemManager.stop();
    this.zooKeeper.close();
  }
  LOG.info("HMaster main thread exiting");
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:57,代码来源:HMaster.java

示例15: tryRecoveringExpiredZKSession

import org.apache.hadoop.hbase.monitoring.MonitoredTask; //导入方法依赖的package包/类
/**
 * We do the following in a different thread.  If it is not completed
 * in time, we will time it out and assume it is not easy to recover.
 *
 * 1. Create a new ZK session. (since our current one is expired)
 * 2. Try to become a primary master again
 * 3. Initialize all ZK based system trackers.
 * 4. Assign root and meta. (they are already assigned, but we need to update our
 * internal memory state to reflect it)
 * 5. Process any RIT if any during the process of our recovery.
 *
 * @return True if we could successfully recover from ZK session expiry.
 * @throws InterruptedException
 * @throws IOException
 * @throws KeeperException
 * @throws ExecutionException
 */
private boolean tryRecoveringExpiredZKSession() throws InterruptedException,
    IOException, KeeperException, ExecutionException {

  this.zooKeeper = new ZooKeeperWatcher(conf, MASTER + ":"
    + this.serverName.getPort(), this, true);

  Callable<Boolean> callable = new Callable<Boolean> () {
    public Boolean call() throws InterruptedException,
        IOException, KeeperException {
      MonitoredTask status =
        TaskMonitor.get().createStatus("Recovering expired ZK session");
      try {
        if (!becomeActiveMaster(status)) {
          return Boolean.FALSE;
        }
        initializeZKBasedSystemTrackers();
        // Update in-memory structures to reflect our earlier Root/Meta assignment.
        assignRootAndMeta(status);
        // process RIT if any
        // TODO: Why does this not call AssignmentManager.joinCluster?  Otherwise
        // we are not processing dead servers if any.
        assignmentManager.processDeadServersAndRegionsInTransition();
        return Boolean.TRUE;
      } finally {
        status.cleanup();
      }
    }
  };

  long timeout =
    conf.getLong("hbase.master.zksession.recover.timeout", 300000);
  java.util.concurrent.ExecutorService executor =
    Executors.newSingleThreadExecutor();
  Future<Boolean> result = executor.submit(callable);
  executor.shutdown();
  if (executor.awaitTermination(timeout, TimeUnit.MILLISECONDS)
      && result.isDone()) {
    Boolean recovered = result.get();
    if (recovered != null) {
      return recovered.booleanValue();
    }
  }
  executor.shutdownNow();
  return false;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:63,代码来源:HMaster.java


注:本文中的org.apache.hadoop.hbase.monitoring.MonitoredTask.cleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。