@Override public List<NamespaceDescriptor> getNamespaces() throws IOException { checkIsRunning(); return getTableNamespaceManager().list().stream() .sorted(NamespaceDescriptor.NAMESPACE_DESCRIPTOR_COMPARATOR) .collect(ImmutableList.toImmutableList()); } }
private synchronized void checkIsRunning() throws ServiceNotRunningException { if (!isRunning()) { throw new ServiceNotRunningException(); } }
@Override public synchronized void doStart() { try { notifyStarted(); this.tableNamespaceManager.start(); } catch (IOException ioe) { notifyFailed(ioe); } }
@Override public long modifyNamespace(NamespaceDescriptor namespaceDescriptor, final NonceKey nonceKey, final ProcedurePrepareLatch latch) throws IOException { return submitProcedure(new ModifyNamespaceProcedure( this.masterServices.getMasterProcedureExecutor().getEnvironment(), namespaceDescriptor, latch), nonceKey); }
@Override protected void doStop() { // This is no stop for the table manager. notifyStopped(); }
@Override public NamespaceDescriptor getNamespace(String name) throws IOException { NamespaceDescriptor nsd = getTableNamespaceManager().get(name); if (nsd == null) throw new NamespaceNotFoundException(name); return nsd; }
private long submitProcedure(final Procedure<MasterProcedureEnv> procedure, final NonceKey nonceKey) throws ServiceNotRunningException { checkIsRunning(); ProcedureExecutor<MasterProcedureEnv> pe = this.masterServices.getMasterProcedureExecutor(); return pe.submitProcedure(procedure, nonceKey); }
@VisibleForTesting protected void initClusterSchemaService() throws IOException, InterruptedException { this.clusterSchemaService = new ClusterSchemaServiceImpl(this); this.clusterSchemaService.startAsync(); try { this.clusterSchemaService.awaitRunning(getConfiguration().getInt( HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS, DEFAULT_HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS), TimeUnit.SECONDS); } catch (TimeoutException toe) { throw new IOException("Timedout starting ClusterSchemaService", toe); } }
@Override public long createNamespace(NamespaceDescriptor namespaceDescriptor, final NonceKey nonceKey, final ProcedurePrepareLatch latch) throws IOException { return submitProcedure(new CreateNamespaceProcedure( this.masterServices.getMasterProcedureExecutor().getEnvironment(), namespaceDescriptor, latch), nonceKey); }
@Override public long deleteNamespace(String name, final NonceKey nonceKey, final ProcedurePrepareLatch latch) throws IOException { return submitProcedure(new DeleteNamespaceProcedure( this.masterServices.getMasterProcedureExecutor().getEnvironment(), name, latch), nonceKey); }