List of usage examples for java.io InterruptedIOException InterruptedIOException
public InterruptedIOException(String s)
InterruptedIOException
with the specified detail message. From source file:org.apache.hadoop.hbase.client.HBaseAdmin.java
/** * @return A new CatalogTracker instance; call {@link #cleanupCatalogTracker(CatalogTracker)} * to cleanup the returned catalog tracker. * @throws org.apache.hadoop.hbase.ZooKeeperConnectionException * @throws IOException//from w ww . jav a 2 s .c om * @see #cleanupCatalogTracker(CatalogTracker) */ private synchronized CatalogTracker getCatalogTracker() throws ZooKeeperConnectionException, IOException { CatalogTracker ct = null; try { ct = new CatalogTracker(this.conf); ct.start(); } catch (InterruptedException e) { // Let it out as an IOE for now until we redo all so tolerate IEs throw (InterruptedIOException) new InterruptedIOException("Interrupted").initCause(e); } return ct; }
From source file:org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure.java
/** * @return True if region cleared RIT, else false if we timed out waiting. * @throws InterruptedIOException/*from w ww. j av a 2s. c o m*/ */ private boolean waitOnRegionToClearRegionsInTransition(AssignmentManager am, final HRegionInfo hri, final int timeout) throws InterruptedIOException { try { if (!am.waitOnRegionToClearRegionsInTransition(hri, timeout)) { // Wait here is to avoid log replay hits current dead server and incur a RPC timeout // when replay happens before region assignment completes. LOG.warn("Region " + hri.getEncodedName() + " didn't complete assignment in time"); return false; } } catch (InterruptedException ie) { throw new InterruptedIOException( "Caught " + ie + " during waitOnRegionToClearRegionsInTransition for " + hri); } return true; }
From source file:org.cloudgraph.hbase.mapreduce.GraphInputFormat.java
@Override public RecordReader<ImmutableBytesWritable, GraphWritable> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { if (table == null) { throw new IOException("Cannot create a record reader because of a" + " previous error. Please look at the previous logs lines from" + " the task's full log for more details."); }//w w w . java 2 s .co m TableSplit tSplit = (TableSplit) split; GraphRecordReader reader = this.graphRecordReader; // if no record reader was provided use default if (reader == null) { reader = new GraphRecordReader(); } Scan sc = tSplit.getScan(); log.debug("SCAN: " + sc.toString()); if (sc.getFilter() != null) { log.info("SPLIT FILTER: " + FilterUtil.printFilterTree(sc.getFilter())); } else { log.info("split scan has no filter"); } sc.setStartRow(tSplit.getStartRow()); sc.setStopRow(tSplit.getEndRow()); reader.setScan(sc); reader.setTable(table); try { reader.initialize(tSplit, context); } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage()); } return reader; }
From source file:org.openymsg.network.Session.java
/** * Call this to connect to the Yahoo server and do all the initial handshaking and accepting of data * /*from ww w.j a v a2s . c o m*/ * @param username * Yahoo id * @param password * password * @param createPingerTask * Session will do it's own thread for pings and keepAlives */ public void login(String username, final String password, final boolean createPingerTask, final boolean searchForAddress) throws IllegalStateException, IOException, AccountLockedException, LoginRefusedException, FailedLoginException { this.identities = new HashMap<String, YahooIdentity>(); this.conferences = new Hashtable<String, YahooConference>(); this.chatroomManager = new ChatroomManager(null, null); if (this.eventDispatchQueue == null) { this.eventDispatchQueue = new EventDispatcher(username, this); this.eventDispatchQueue.start(); } if (username == null || username.length() == 0) { this.setSessionStatus(SessionState.FAILED); throw new IllegalArgumentException("Argument 'username' cannot be null or an empty String."); } if (password == null || password.length() == 0) { this.setSessionStatus(SessionState.FAILED); throw new IllegalArgumentException("Argument 'password' cannot be null or an empty String."); } // Check the session status first synchronized (this) { if (this.getSessionStatus() != SessionState.UNSTARTED) throw new IllegalStateException("Session should be unstarted"); this.setSessionStatus(SessionState.INITIALIZING); } // Yahoo ID's are apparently always lower case username = username.toLowerCase(); // Reset session and init some variables resetData(); this.roster = new Roster(this); this.addSessionListener(this.roster); this.loginID = new YahooIdentity(username); this.primaryID = null; this.password = password; this.sessionId = 0; this.imvironment = "0"; try { // Create the socket and threads (ipThread, sessionPingRunnable and // maybe eventDispatchQueue) log.trace("Opening session..."); openSession(createPingerTask, searchForAddress); // Begin login process log.trace("Transmitting auth..."); this.setSessionStatus(SessionState.CONNECTING); transmitAuth(); // Wait until connection or timeout long timeout = System.currentTimeMillis() + Util.loginTimeout(NetworkConstants.LOGIN_TIMEOUT); while (this.getSessionStatus() != SessionState.LOGGED_ON && this.getSessionStatus() != SessionState.FAILED && !past(timeout) && this.loginException == null && !this.cancelLogin) try { Thread.sleep(10); } catch (InterruptedException e) { // ignore } log.trace("finished waiting for connection: " + this.getSessionStatus() + "/" + past(timeout) + "/" + this.loginException); if (this.cancelLogin) { forceCloseSession(); this.setSessionStatus(SessionState.UNSTARTED); return; } if (past(timeout)) { this.setSessionStatus(SessionState.FAILED); throw new InterruptedIOException("Login timed out"); } if (this.getSessionStatus() == SessionState.FAILED) { if (this.loginException instanceof FailedLoginException) throw (FailedLoginException) this.loginException; throw (LoginRefusedException) this.loginException; } } finally { // Logon failure? When network input finishes, all supporting // threads are stopped. if (this.getSessionStatus() != SessionState.LOGGED_ON) { log.error("Never logged in, sessionStatus is: " + this.getSessionStatus()); closeSession(); } } }
From source file:org.openlaszlo.data.HTTPDataSource.java
/** * @param since last modified time to use * @param req/*w w w . j a va 2s. c om*/ * @param url if null, ignored * @param redirCount number of redirs we've done */ public static HttpData getDataOnce(HttpServletRequest req, HttpServletResponse res, long since, String surl, int redirCount, int timeout) throws IOException, HttpException, DataSourceException, MalformedURLException { HttpMethodBase request = null; HostConfiguration hcfg = new HostConfiguration(); /* [todo hqm 2006-02-01] Anyone know why this code was here? It is setting the mime type to something which just confuses the DHTML parser. if (res != null) { res.setContentType("application/x-www-form-urlencoded;charset=UTF-8"); } */ try { // TODO: [2002-01-09 bloch] cope with cache-control // response headers (no-store, no-cache, must-revalidate, // proxy-revalidate). if (surl == null) { surl = getURL(req); } if (surl == null || surl.equals("")) { throw new MalformedURLException( /* (non-Javadoc) * @i18n.test * @org-mes="url is empty or null" */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-312")); } String reqType = ""; String headers = ""; if (req != null) { reqType = req.getParameter("reqtype"); headers = req.getParameter("headers"); } boolean isPost = false; mLogger.debug("reqtype = " + reqType); if (reqType != null && reqType.equals("POST")) { request = new LZPostMethod(); request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); isPost = true; mLogger.debug("setting POST req method"); } else if (reqType != null && reqType.equals("PUT")) { request = new LZPutMethod(); // todo [hqm 2007] treat PUT like POST? isPost = true; mLogger.debug("setting PUT req method"); } else if (reqType != null && reqType.equals("DELETE")) { request = new LZDeleteMethod(); mLogger.debug("setting DELETE req method"); } else { mLogger.debug("setting GET (default) req method"); request = new LZGetMethod(); } request.getParams().setVersion(mUseHttp11 ? HttpVersion.HTTP_1_1 : HttpVersion.HTTP_1_0); // Proxy the request headers if (req != null) { LZHttpUtils.proxyRequestHeaders(req, request); } // Set headers from query string if (headers != null && headers.length() > 0) { StringTokenizer st = new StringTokenizer(headers, "\n"); while (st.hasMoreTokens()) { String h = st.nextToken(); int i = h.indexOf(":"); if (i > -1) { String n = h.substring(0, i); String v = h.substring(i + 2, h.length()); request.setRequestHeader(n, v); mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="setting header " + p[0] + "=" + p[1] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-359", new Object[] { n, v })); } } } mLogger.debug("Parsing url"); URI uri = LZHttpUtils.newURI(surl); try { hcfg.setHost(uri); } catch (Exception e) { throw new MalformedURLException( /* (non-Javadoc) * @i18n.test * @org-mes="can't form uri from " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-376", new Object[] { surl })); } // This gets us the url-encoded (escaped) path and query string String path = uri.getEscapedPath(); String query = uri.getEscapedQuery(); mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="encoded path: " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-389", new Object[] { path })); mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="encoded query: " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-397", new Object[] { query })); // This call takes a decoded (unescaped) path request.setPath(path); boolean hasQuery = (query != null && query.length() > 0); String rawcontent = null; // Newer rawpost protocol puts lzpostbody as a separate // top level query arg in the request. rawcontent = req.getParameter("lzpostbody"); if (isPost) { // Older rawpost protocol put the "lzpostbody" arg // embedded in the "url" args's query args if (rawcontent == null && hasQuery) { rawcontent = findQueryArg("lzpostbody", query); } if (rawcontent != null) { // Get the unescaped query string ((EntityEnclosingMethod) request).setRequestEntity(new StringRequestEntity(rawcontent)); } else if (hasQuery) { StringTokenizer st = new StringTokenizer(query, "&"); while (st.hasMoreTokens()) { String it = st.nextToken(); int i = it.indexOf("="); if (i > 0) { String n = it.substring(0, i); String v = it.substring(i + 1, it.length()); // POST encodes values during request ((PostMethod) request).addParameter(n, URLDecoder.decode(v, "UTF-8")); } else { mLogger.warn( /* (non-Javadoc) * @i18n.test * @org-mes="ignoring bad token (missing '=' char) in query string: " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-429", new Object[] { it })); } } } } else { // This call takes an encoded (escaped) query string request.setQueryString(query); } // Put in the If-Modified-Since headers if (since != -1) { String lms = LZHttpUtils.getDateString(since); request.setRequestHeader(LZHttpUtils.IF_MODIFIED_SINCE, lms); mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="proxying lms: " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-450", new Object[] { lms })); } mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="setting up http client" */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-460")); HttpClient htc = null; if (mConnectionMgr != null) { htc = new HttpClient(mConnectionMgr); } else { htc = new HttpClient(); } htc.setHostConfiguration(hcfg); // This is the data timeout mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="timeout set to " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-478", new Object[] { timeout })); htc.getParams().setSoTimeout(timeout); // Set connection timeout the same htc.getHttpConnectionManager().getParams().setConnectionTimeout(mConnectionTimeout); // Set timeout for getting a connection htc.getParams().setConnectionManagerTimeout(mConnectionPoolTimeout); // TODO: [2003-03-05 bloch] this should be more configurable (per app?) if (!isPost) { request.setFollowRedirects(mFollowRedirects > 0); } long t1 = System.currentTimeMillis(); mLogger.debug("starting remote request"); int rc = htc.executeMethod(hcfg, request); String status = HttpStatus.getStatusText(rc); if (status == null) { status = "" + rc; } mLogger.debug( /* (non-Javadoc) * @i18n.test * @org-mes="remote response status: " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-504", new Object[] { status })); HttpData data = null; if (isRedirect(rc) && mFollowRedirects > redirCount) { String loc = request.getResponseHeader("Location").toString(); String hostURI = loc.substring(loc.indexOf(": ") + 2, loc.length()); mLogger.info( /* (non-Javadoc) * @i18n.test * @org-mes="Following URL from redirect: " + p[0] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-517", new Object[] { hostURI })); long t2 = System.currentTimeMillis(); if (timeout > 0) { timeout -= (t2 - t1); if (timeout < 0) { throw new InterruptedIOException( /* (non-Javadoc) * @i18n.test * @org-mes=p[0] + " timed out after redirecting to " + p[1] */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-529", new Object[] { surl, loc })); } } data = getDataOnce(req, res, since, hostURI, redirCount++, timeout); } else { data = new HttpData(request, rc); } if (req != null && res != null) { // proxy response headers LZHttpUtils.proxyResponseHeaders(request, res, req.isSecure()); } return data; } catch (ConnectTimeoutException ce) { // Transduce to an InterrupedIOException, since lps takes these to be timeouts. if (request != null) { request.releaseConnection(); } throw new InterruptedIOException( /* (non-Javadoc) * @i18n.test * @org-mes="connecting to " + p[0] + ":" + p[1] + " timed out beyond " + p[2] + " msecs." */ org.openlaszlo.i18n.LaszloMessages.getMessage(HTTPDataSource.class.getName(), "051018-557", new Object[] { hcfg.getHost(), hcfg.getPort(), mConnectionTimeout })); } catch (HttpRecoverableException hre) { if (request != null) { request.releaseConnection(); } throw hre; } catch (HttpException e) { if (request != null) { request.releaseConnection(); } throw e; } catch (IOException ie) { if (request != null) { request.releaseConnection(); } throw ie; } catch (RuntimeException e) { if (request != null) { request.releaseConnection(); } throw e; } }
From source file:com.alibaba.wasp.client.WaspAdmin.java
/** * Creates a new table with an initial set of empty entityGroups defined by * the specified split keys. The total number of entityGroups created will be * the number of split keys plus one. Synchronous operation. Note : Avoid * passing empty split key.// w ww.j a v a 2 s . com * * @param desc * table descriptor for table * @param splitKeys * array of split keys for the initial entityGroups of the table * * @throws IllegalArgumentException * if the table name is reserved, if the split keys are repeated and * if the split key has empty byte array. * @throws com.alibaba.wasp.MasterNotRunningException * if master is not running * @throws com.alibaba.wasp.TableExistsException * if table already exists (If concurrent threads, the table may * have been created between test-for-existence and * attempt-at-creation). * @throws java.io.IOException */ public void createTable(final FTable desc, byte[][] splitKeys) throws IOException { FTable.isLegalTableName(desc.getTableName()); try { createTableAsync(desc, splitKeys); } catch (SocketTimeoutException ste) { LOG.warn("Creating " + desc.getTableName() + " took too long", ste); } final byte[] tableNameBytes = Bytes.toBytes(desc.getTableName()); int numRegs = splitKeys == null ? 1 : splitKeys.length + 1; int prevRegCount = 0; boolean doneWithMetaScan = false; for (int tries = 0; tries < this.numRetries * this.retryLongerMultiplier; ++tries) { if (!doneWithMetaScan) { // Wait for new table to come on-line MasterAdminProtos.FetchEntityGroupSizeResponse res = execute( new MasterAdminCallable<MasterAdminProtos.FetchEntityGroupSizeResponse>() { @Override public MasterAdminProtos.FetchEntityGroupSizeResponse call() throws ServiceException { MasterAdminProtos.FetchEntityGroupSizeRequest request = RequestConverter .buildFetchEntityGroupSizeRequest(tableNameBytes); return masterAdmin.fetchEntityGroupSize(null, request); } }); int actualEgCount = res.getEgSize(); if (actualEgCount != numRegs && desc.isRootTable()) { if (tries == this.numRetries * this.retryLongerMultiplier - 1) { throw new EntityGroupOfflineException("Only " + actualEgCount + " of " + numRegs + " entityGroups are online; retries exhausted."); } try { // Sleep Thread.sleep(getPauseTime(tries)); } catch (InterruptedException e) { throw new InterruptedIOException("Interrupted when opening" + " entityGroups; " + actualEgCount + " of " + numRegs + " entityGroups processed so far"); } if (actualEgCount > prevRegCount) { // Making progress prevRegCount = actualEgCount; tries = -1; } } else { doneWithMetaScan = true; tries = -1; } } else if (isTableEnabled(desc.getTableName())) { return; } else { try { // Sleep Thread.sleep(getPauseTime(tries)); } catch (InterruptedException e) { throw new InterruptedIOException( "Interrupted when waiting" + " for table to be enabled; meta scan was done"); } } } throw new TableNotEnabledException( "Retries exhausted while still waiting for table: " + desc.getTableName() + " to be enabled"); }
From source file:org.apache.hadoop.hbase.regionserver.HStore.java
/** * Creates an unsorted list of StoreFile loaded in parallel * from the given directory.//from w ww .j av a2 s .co m * @throws IOException */ private List<StoreFile> loadStoreFiles() throws IOException { Collection<StoreFileInfo> files = fs.getStoreFiles(getColumnFamilyName()); if (files == null || files.size() == 0) { return new ArrayList<StoreFile>(); } // initialize the thread pool for opening store files in parallel.. ThreadPoolExecutor storeFileOpenerThreadPool = this.region .getStoreFileOpenAndCloseThreadPool("StoreFileOpenerThread-" + this.getColumnFamilyName()); CompletionService<StoreFile> completionService = new ExecutorCompletionService<StoreFile>( storeFileOpenerThreadPool); int totalValidStoreFile = 0; for (final StoreFileInfo storeFileInfo : files) { // open each store file in parallel completionService.submit(new Callable<StoreFile>() { @Override public StoreFile call() throws IOException { StoreFile storeFile = createStoreFileAndReader(storeFileInfo); return storeFile; } }); totalValidStoreFile++; } ArrayList<StoreFile> results = new ArrayList<StoreFile>(files.size()); IOException ioe = null; try { for (int i = 0; i < totalValidStoreFile; i++) { try { Future<StoreFile> future = completionService.take(); StoreFile storeFile = future.get(); long length = storeFile.getReader().length(); this.storeSize += length; this.totalUncompressedBytes += storeFile.getReader().getTotalUncompressedBytes(); if (LOG.isDebugEnabled()) { LOG.debug("loaded " + storeFile.toStringDetailed()); } results.add(storeFile); } catch (InterruptedException e) { if (ioe == null) ioe = new InterruptedIOException(e.getMessage()); } catch (ExecutionException e) { if (ioe == null) ioe = new IOException(e.getCause()); } } } finally { storeFileOpenerThreadPool.shutdownNow(); } if (ioe != null) { // close StoreFile readers for (StoreFile file : results) { try { if (file != null) file.closeReader(true); } catch (IOException e) { LOG.warn(e.getMessage()); } } throw ioe; } return results; }
From source file:byps.http.HActiveMessages.java
public synchronized BContentStream getIncomingOrOutgoingStream(Long streamId, long timeoutMillis) throws IOException, BException { if (log.isDebugEnabled()) log.debug("getIncomingStream(streamId=" + streamId); long t1 = System.currentTimeMillis(); BContentStream stream = null;/*from ww w . j ava 2 s.co m*/ while (timeoutMillis > 0) { stream = incomingStreams != null ? incomingStreams.get(streamId) : null; if (stream != null) break; stream = outgoingStreams != null ? outgoingStreams.get(streamId) : null; if (stream != null) break; // Wait until the requested stream is received long t2 = System.currentTimeMillis(); timeoutMillis = timeoutMillis - (t2 - t1); if (timeoutMillis <= 0) { if (log.isDebugEnabled()) log.debug("Stream not found, streamId=" + streamId); throw new FileNotFoundException("Stream not found, streamId=" + streamId); } // Wait not more than 10s to make sure, // that we never will hang here because of a lost notify(). long to = Math.min(timeoutMillis, 10 * 1000); if (log.isDebugEnabled()) log.debug("wait for stream=" + streamId + ", timeout=" + to); try { wait(to); } catch (InterruptedException e) { throw new InterruptedIOException("Wait for stream=" + streamId + " interrupted."); } } if (log.isDebugEnabled()) log.debug(")getIncomingStream=" + stream); return stream; }
From source file:org.apache.hadoop.hbase.client.crosssite.CrossSiteHBaseAdmin.java
/** * Enables the cross site tables.//www.j a v a 2 s . co m * * Directly check the state of the znode. * * @param tableName * @throws IOException * @throws KeeperException * @throws InterruptedException * @throws ExecutionException */ private void enableTableInternal(final String tableName) throws IOException, KeeperException, InterruptedException, ExecutionException { if (LOG.isDebugEnabled()) { LOG.debug("Enabling the cross site table " + tableName); } long start = System.currentTimeMillis(); for (int tries = 0; tries < this.numRetries * this.retryLongerMultiplier; ++tries) { boolean locked = false; try { locked = znodes.lockTable(tableName); if (locked) { final boolean peersAvailable = isReplicatedTable(znodes.getTableDesc(tableName)); TableState tableState = znodes.getTableState(tableName); if (LOG.isDebugEnabled()) { LOG.debug("The state of " + tableName + " is " + tableState); } if (!TableState.DISABLED.equals(tableState)) { if (TableState.ENABLED.equals(tableState)) { throw new TableNotDisabledException(tableName); } else if (TableState.ENABLING.equals(tableState) || TableState.DISABLING.equals(tableState)) { LOG.info("Trying to enable a cross site table " + tableName + " in the ENABLING/DISABLING state"); } else { throw new TableAbnormalStateException(tableName + ":" + tableState); } } Map<String, ClusterInfo> clusterInfo = znodes.listClusterInfos(); // update the state to enabling znodes.setTableState(tableName, TableState.ENABLING); // access the cluster one by one List<Future<Void>> results = new ArrayList<Future<Void>>(); for (final Entry<String, ClusterInfo> entry : clusterInfo.entrySet()) { final String clusterName = entry.getKey(); results.add(pool.submit(new CrossSiteCallable<Void>(conf) { @Override public Void call() throws Exception { String clusterTableName = CrossSiteUtil.getClusterTableName(tableName, clusterName); HBaseAdmin admin = createHBaseAmin(configuration, entry.getValue().getAddress()); try { enableTable(admin, clusterTableName); // should enable on the peers if (peersAvailable) { ClusterInfo ci = entry.getValue(); if (ci.getPeers() != null && !ci.getPeers().isEmpty()) { for (ClusterInfo peer : ci.getPeers()) { if (LOG.isDebugEnabled()) { LOG.debug("Enabling table " + clusterTableName + " in the peer " + peer); } HBaseAdmin peerAdmin = createHBaseAmin(configuration, peer.getAddress()); String peerTableName = CrossSiteUtil.getPeerClusterTableName( tableName, clusterName, peer.getName()); try { // When table is not present in the peer cluster, let Exception be thrown // and state of the table continue in ENABLING enableTable(peerAdmin, peerTableName); } finally { try { peerAdmin.close(); } catch (IOException e) { LOG.warn("Fail to close the HBaseAdmin of peers", e); } } } } } } finally { try { admin.close(); } catch (IOException e) { LOG.warn("Fail to close the HBaseAdmin", e); } } return null; } })); } try { for (Future<Void> result : results) { // directly throw the exception. result.get(); } // update the znode state znodes.setTableState(tableName, TableState.ENABLED); } catch (Exception e) { LOG.error("Fail to enable the cross site table " + tableName, e); throw new IOException(e); } LOG.info("The cross site table " + tableName + " is enabled"); return; } } finally { if (locked) { znodes.unlockTable(tableName); } } if (tries < this.numRetries * this.retryLongerMultiplier - 1) { try { // Sleep Thread.sleep(getPauseTime(tries)); } catch (InterruptedException e) { throw new InterruptedIOException("Interrupted when waiting" + " for cross site HTable enable"); } } } throw new IOException( "Table '" + tableName + "' not yet enabled, after " + (System.currentTimeMillis() - start) + "ms."); }
From source file:org.apache.hadoop.hdfs.DataStreamer.java
/** * wait for the ack of seqno//from w w w. j ava 2s . c o m * * @param seqno the sequence number to be acked * @throws IOException */ void waitForAckedSeqno(long seqno) throws IOException { TraceScope scope = Trace.startSpan("waitForAckedSeqno", Sampler.NEVER); try { if (LOG.isDebugEnabled()) { LOG.debug("Waiting for ack for: " + seqno); } long begin = Time.monotonicNow(); try { synchronized (dataQueue) { while (!streamerClosed) { checkClosed(); if (lastAckedSeqno >= seqno) { break; } try { dataQueue.wait(1000); // when we receive an ack, we notify on // dataQueue } catch (InterruptedException ie) { throw new InterruptedIOException( "Interrupted while waiting for data to be acknowledged by pipeline"); } } } checkClosed(); } catch (ClosedChannelException e) { } long duration = Time.monotonicNow() - begin; if (duration > dfsclientSlowLogThresholdMs) { LOG.warn("Slow waitForAckedSeqno took " + duration + "ms (threshold=" + dfsclientSlowLogThresholdMs + "ms)"); } } finally { scope.close(); } }