List of usage examples for org.apache.hadoop.metrics2.util MBeans unregister
static public void unregister(ObjectName mbeanName)
From source file:com.alibaba.wasp.fserver.FServer.java
License:Apache License
@Override public void run() { // try {/*from w w w. j a v a 2 s. c om*/ // preRegistrationInitialization(); // } catch (Exception e) { // this.rpcServer.stop(); // abort("Fatal exception during initialization", e); // } try { initializeZooKeeper(); } catch (Exception t) { this.rpcServer.stop(); abort("Initialization of FS failed. Hence aborting FS.", t); } try { while (keepLooping()) { FServerStartupResponse w = reportForDuty(); if (w == null) { LOG.warn("reportForDuty failed; sleeping and then retrying."); this.sleeper.sleep(); } else { handleReportForDutyResponse(w); break; } } // We registered with the Master. Go into run mode. long lastMsg = 0; long oldRequestCount = -1; // The main run loop. while (!this.stopped && isHealthy()) { if (!isClusterUp()) { if (isOnlineEntityGroupsEmpty()) { stop("Exiting; cluster shutdown set and not carrying any entityGroups"); } else if (!this.stopping) { this.stopping = true; LOG.info("Closing user entityGroups"); closeUserEntityGroups(this.abortRequested); } else if (this.stopping) { boolean allUserEntityGroupsOffline = areAllUserEntityGroupsOffline(); if (allUserEntityGroupsOffline) { // Set stopped if no requests since last time we went around the // loop. if (oldRequestCount == this.requestCount.get()) { stop("Stopped;"); break; } oldRequestCount = this.requestCount.get(); } else { // Make sure all entityGroups have been closed -- some // entityGroups may // have not got it because we were splitting at the time of // the call to closeUserEntityGroups. closeUserEntityGroups(this.abortRequested); } LOG.debug("Waiting on " + getOnlineEntityGroupsAsPrintableString()); } driver.close(); } long now = System.currentTimeMillis(); if ((now - lastMsg) >= msgInterval) { doMetrics(); tryFServerReport(lastMsg, now); lastMsg = System.currentTimeMillis(); } if (!this.stopped) this.sleeper.sleep(); } } catch (Throwable t) { abort("Unhandled exception: " + t.getMessage(), t); } // Run shutdown. if (mxBean != null) { MBeans.unregister(mxBean); mxBean = null; } this.leases.closeAfterLeasesExpire(); this.rpcServer.stop(); if (this.splitThread != null) { this.splitThread.interruptIfNecessary(); } if (this.killed) { // Just skip out w/o closing entityGroups. Used when testing. } else if (abortRequested) { closeUserEntityGroups(abortRequested); // Don't leave any open file // handles LOG.info("aborting server " + this.serverNameFromMasterPOV); } else { closeUserEntityGroups(abortRequested); closeAllScanners(); LOG.info("stopping server " + this.serverNameFromMasterPOV); } globalEntityGroup.close(); if (!this.killed) { waitOnAllEntityGroupsToClose(abortRequested); LOG.info("stopping server " + this.serverNameFromMasterPOV + "; all entityGroups closed."); } // Make sure the proxy is down. if (this.waspMaster != null) { WaspRPC.stopProxy(this.waspMaster); this.waspMaster = null; } this.leases.close(); if (infoServer != null) { try { infoServer.stop(); } catch (Exception e) { LOG.warn("Failed stop infoServer", e); } } if (this.broker != null) { try { this.broker.close(); } catch (IOException e) { LOG.warn("Failed close broker", e); } } if (!killed) { join(); } try { deleteMyEphemeralNode(); } catch (KeeperException e) { LOG.warn("Failed deleting my ephemeral node", e); } // We may have failed to delete the znode at the previous step, but // we delete the file anyway: a second attempt to delete the znode is likely // to fail again. ZNodeClearer.deleteMyEphemeralNodeOnDisk(); this.zooKeeper.close(); LOG.info("stopping server " + this.serverNameFromMasterPOV + "; zookeeper connection closed."); LOG.info(Thread.currentThread().getName() + " exiting"); }
From source file:com.alibaba.wasp.master.FMaster.java
License:Apache License
public void shutdown() throws IOException { if (mxBean != null) { MBeans.unregister(mxBean); mxBean = null;// ww w . jav a2 s. co m } if (this.assignmentManager != null) this.assignmentManager.shutdown(); if (this.serverManager != null) this.serverManager.shutdownCluster(); try { if (this.clusterStatusTracker != null) { this.clusterStatusTracker.setClusterDown(); } } catch (KeeperException e) { LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e); } }
From source file:org.apache.cassandra.hadoop.trackers.TrackerInitializer.java
License:Apache License
public static void stopTaskTracker() throws InterruptedException, IOException { MBeans.unregister(taskTrackerMBean); taskTrackerThread.interrupt();//from w w w .ja v a2s . c o m if (taskTracker != null) { taskTracker.shutdown(); } taskTrackerThread.join(60000); }