private synchronized Table getNamespaceTable() throws IOException { if (!isTableAvailableAndInitialized()) { throw new IOException(this.getClass().getName() + " isn't ready to serve"); } return nsTable; }
void checkNamespaceManagerReady() throws IOException { checkInitialized(); if (tableNamespaceManager == null || !tableNamespaceManager.isTableAvailableAndInitialized()) { throw new IOException("Table Namespace Manager not ready yet, try again later"); } } /**
public synchronized NamespaceDescriptor get(String name) throws IOException { if (!isTableAvailableAndInitialized()) return null; return zkNamespaceManager.get(name); }
public void start() throws IOException { if (!MetaTableAccessor.tableExists(masterServices.getConnection(), TableName.NAMESPACE_TABLE_NAME)) { LOG.info("Namespace table not found. Creating..."); createNamespaceTable(masterServices); } try { // Wait for the namespace table to be assigned. // If timed out, we will move ahead without initializing it. // So that it should be initialized later on lazily. long startTime = EnvironmentEdgeManager.currentTime(); int timeout = conf.getInt(NS_INIT_TIMEOUT, DEFAULT_NS_INIT_TIMEOUT); while (!isTableAssigned()) { if (EnvironmentEdgeManager.currentTime() - startTime + 100 > timeout) { // We can't do anything if ns is not online. throw new IOException("Timedout " + timeout + "ms waiting for namespace table to " + "be assigned"); } Thread.sleep(100); } } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } // initialize namespace table isTableAvailableAndInitialized(); }