private void applyFilters(ScanTreeNode unfilteredRoot, ScanTreeNode issuesFilteredRoot, ScanTreeNode licenseFilteredRoot, MutableBoolean severitySelected, MutableBoolean licenseSelected) { severitySelected.setValue(isSeveritySelected(unfilteredRoot)); licenseSelected.setValue(isLicenseSelected(unfilteredRoot)); for (int i = 0; i < unfilteredRoot.getChildCount(); i++) { ScanTreeNode unfilteredChild = (ScanTreeNode) unfilteredRoot.getChildAt(i); ScanTreeNode filteredSeverityChild = getFilteredTreeNode(unfilteredChild); ScanTreeNode filteredLicenseChild = (ScanTreeNode) unfilteredChild.clone(); MutableBoolean childSeveritySelected = new MutableBoolean(); MutableBoolean childLicenseSelected = new MutableBoolean(); applyFilters(unfilteredChild, filteredSeverityChild, filteredLicenseChild, childSeveritySelected, childLicenseSelected); if (childSeveritySelected.booleanValue()) { severitySelected.setValue(true); issuesFilteredRoot.add(filteredSeverityChild); } if (childLicenseSelected.booleanValue()) { licenseSelected.setValue(true); licenseFilteredRoot.add(filteredLicenseChild); } } }
public Slot allocSlot(DatanodeInfo datanode, DomainPeer peer, MutableBoolean usedPeer, ExtendedBlockId blockId, String clientName) throws IOException { lock.lock(); try { if (closed) { LOG.trace(this + ": the DfsClientShmManager isclosed."); return null; } EndpointShmManager shmManager = datanodes.get(datanode); if (shmManager == null) { shmManager = new EndpointShmManager(datanode); datanodes.put(datanode, shmManager); } return shmManager.allocSlot(peer, usedPeer, clientName, blockId); } finally { lock.unlock(); } }
@Override public List<TaxEnt> getTaxEnt(TaxEnt q, MutableBoolean askQuestion) throws FloraOnException { // TODO when imported name has not subsp., doesn't work, e.g. cistus ladanifer sulcatus if(q.getName() == null || q.getName().equals("")) throw new QueryException("Invalid blank name."); ArangoCursor<TaxEnt> cursor; String query = AQLQueries.getString("NodeWorkerDriver.12", q.getName().substring(0, 3)); // FIXME: when no rank is specified! try { cursor = database.query(query, null, null, TaxEnt.class); if(!cursor.hasNext()) // node does not exist return Collections.emptyList(); } catch (ArangoDBException e) { throw new DatabaseException(e.getMessage()); } return matchTaxEntToTaxEntList(q, cursor, askQuestion); }
/** * Constructor */ public SwingView() { super(FRAME_TITLE); // Content this.cardDialog = new CardPlayDialog(this); this.deckButton = new DeckButton(); this.discardPileButtons = new HashMap<Suit, DiscardPileButton>(); this.playerOneExpeditionLabels = new HashMap<Suit, ExpedLabel>(); this.playerOneTotalLabel = new JLabel(); this.playerTwoExpeditionLabels = new HashMap<Suit, ExpedLabel>(); this.playerTwoTotalLabel = new JLabel(); this.playerTwoHandButtons = new HandButton[Hand.LIMIT]; this.popupExpedMenu = new JPopupMenu(); this.popupExpedMenu.setEnabled(false); this.showRunningScores = new MutableBoolean(true); this.statusBar = new JLabel(); // Menu Bar menuBar = new MenuBar(this.showRunningScores); menuBar.addShowRunningScoresListener(new ShowRunningScoresListener()); setJMenuBar(menuBar); // Only adding one component to this frame allows it to have a border add(getFramePanel()); setResizable(false); pack(); setLocationRelativeTo(null); }
private void waitForReplicaAnchorStatus(final ShortCircuitCache cache, final ExtendedBlock block, final boolean expectedIsAnchorable, final boolean expectedIsAnchored, final int expectedOutstandingMmaps) throws Exception { GenericTestUtils.waitFor(new Supplier<Boolean>() { @Override public Boolean get() { final MutableBoolean result = new MutableBoolean(false); cache.accept(new CacheVisitor() { @Override public void visit(int numOutstandingMmaps, Map<ExtendedBlockId, ShortCircuitReplica> replicas, Map<ExtendedBlockId, InvalidToken> failedLoads, Map<Long, ShortCircuitReplica> evictable, Map<Long, ShortCircuitReplica> evictableMmapped) { Assert.assertEquals(expectedOutstandingMmaps, numOutstandingMmaps); ShortCircuitReplica replica = replicas.get(ExtendedBlockId.fromExtendedBlock(block)); Assert.assertNotNull(replica); Slot slot = replica.getSlot(); if ((expectedIsAnchorable != slot.isAnchorable()) || (expectedIsAnchored != slot.isAnchored())) { LOG.info("replica " + replica + " has isAnchorable = " + slot.isAnchorable() + ", isAnchored = " + slot.isAnchored() + ". Waiting for isAnchorable = " + expectedIsAnchorable + ", isAnchored = " + expectedIsAnchored); return; } result.setValue(true); } }); return result.toBoolean(); } }, 10, 60000); }
@Test(timeout=60000) public void testExpiry() throws Exception { final ShortCircuitCache cache = new ShortCircuitCache(2, 1, 1, 10000000, 1, 10000000, 0); final TestFileDescriptorPair pair = new TestFileDescriptorPair(); ShortCircuitReplicaInfo replicaInfo1 = cache.fetchOrCreate( new ExtendedBlockId(123, "test_bp1"), new SimpleReplicaCreator(123, cache, pair)); Preconditions.checkNotNull(replicaInfo1.getReplica()); Preconditions.checkState(replicaInfo1.getInvalidTokenException() == null); pair.compareWith(replicaInfo1.getReplica().getDataStream(), replicaInfo1.getReplica().getMetaStream()); replicaInfo1.getReplica().unref(); final MutableBoolean triedToCreate = new MutableBoolean(false); do { Thread.sleep(10); ShortCircuitReplicaInfo replicaInfo2 = cache.fetchOrCreate( new ExtendedBlockId(123, "test_bp1"), new ShortCircuitReplicaCreator() { @Override public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() { triedToCreate.setValue(true); return null; } }); if ((replicaInfo2 != null) && (replicaInfo2.getReplica() != null)) { replicaInfo2.getReplica().unref(); } } while (triedToCreate.isFalse()); cache.close(); }
public void handleThrowable(Throwable t1, ServerName serverName, MutableBoolean couldNotCommunicateWithServer) throws IOException { Throwable t2 = translateException(t1); boolean isLocalException = !(t2 instanceof RemoteException); if (isLocalException && isConnectionException(t2)) { couldNotCommunicateWithServer.setValue(true); handleFailureToServer(serverName, t2); } }
private void addToken(TokenGroup group, int start, int end, String charString, MutableBoolean isNewLine, Token lastToken) { Token token = new Token(start, end, charString); if (isNewLine.booleanValue()) { group.addNewLine(start); isNewLine.setValue(false); } token.setPreceedBySpace(start - lastToken.getEnd() > 0); int spaces = 0; if (lastToken != null && lastToken.getEnd() != 0) { int endLast = lastToken.getEnd(); spaces = lastToken.getSpaceOffset(); if (start == endLast) { spaces++; } else { spaces -= Math.max(0, start - endLast - 1); } } token.setSpaceOffset(spaces); // Normalization String n; if (charString.length() == 1) { int c = charString.charAt(0); n = normalizedChars.get(c); } else { n = normalizedStrings.get(charString); } if (n != null) { token.setNormForm(n); } lastToken.updateByToken(token); group.addToken(token); }
@Test(timeout=100000) public void testExpiry() throws Exception { final ShortCircuitCache cache = new ShortCircuitCache(2, 1, 1, 10000000, 1, 10000000, 0); final TestFileDescriptorPair pair = new TestFileDescriptorPair(); ShortCircuitReplicaInfo replicaInfo1 = cache.fetchOrCreate( new ExtendedBlockId(123, "test_bp1"), new SimpleReplicaCreator(123, cache, pair)); Preconditions.checkNotNull(replicaInfo1.getReplica()); Preconditions.checkState(replicaInfo1.getInvalidTokenException() == null); pair.compareWith(replicaInfo1.getReplica().getDataStream(), replicaInfo1.getReplica().getMetaStream()); replicaInfo1.getReplica().unref(); final MutableBoolean triedToCreate = new MutableBoolean(false); do { Thread.sleep(10); ShortCircuitReplicaInfo replicaInfo2 = cache.fetchOrCreate( new ExtendedBlockId(123, "test_bp1"), new ShortCircuitReplicaCreator() { @Override public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() { triedToCreate.setValue(true); return null; } }); if ((replicaInfo2 != null) && (replicaInfo2.getReplica() != null)) { replicaInfo2.getReplica().unref(); } } while (triedToCreate.isFalse()); cache.close(); }
private <C extends Containerable> boolean processAuthorizationContainerDelta(ContainerDelta<C> cdelta, final Collection<ItemPath> allowedItems) { final MutableBoolean itemDecision = new MutableBoolean(true); cdelta.foreach(cval -> { if (!isContainerAllowed(cval, allowedItems)) { itemDecision.setValue(false); } }); return itemDecision.booleanValue(); }
@Override protected FrameBlock readBlobFromRDD(RDDObject rdd, MutableBoolean status) throws IOException { //note: the read of a frame block from an RDD might trigger //lazy evaluation of pending transformations. RDDObject lrdd = rdd; //prepare return status (by default only collect) status.setValue(false); MetaDataFormat iimd = (MetaDataFormat) _metaData; MatrixCharacteristics mc = iimd.getMatrixCharacteristics(); int rlen = (int)mc.getRows(); int clen = (int)mc.getCols(); //handle missing schema if necessary ValueType[] lschema = (_schema!=null) ? _schema : UtilFunctions.nCopies(clen>=1 ? (int)clen : 1, ValueType.STRING); FrameBlock fb = null; try { //prevent unnecessary collect through rdd checkpoint if( rdd.allowsShortCircuitCollect() ) { lrdd = (RDDObject)rdd.getLineageChilds().get(0); } //collect frame block from binary block RDD fb = SparkExecutionContext.toFrameBlock(lrdd, lschema, rlen, clen); } catch(DMLRuntimeException ex) { throw new IOException(ex); } //sanity check correct output if( fb == null ) throw new IOException("Unable to load frame from rdd."); return fb; }
private <O extends ObjectType, R extends ObjectType> boolean checkProhibitedValues(String newPassword, ProhibitedValuesType prohibitedValuesType, AbstractValuePolicyOriginResolver<O> originResolver, Consumer<ProhibitedValueItemType> failAction, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { if (prohibitedValuesType == null || originResolver == null) { return true; } MutableBoolean isAcceptable = new MutableBoolean(true); for (ProhibitedValueItemType prohibitedItemType: prohibitedValuesType.getItem()) { ItemPathType itemPathType = prohibitedItemType.getPath(); if (itemPathType == null) { throw new SchemaException("No item path defined in prohibited item in "+shortDesc); } ItemPath itemPath = itemPathType.getItemPath(); ResultHandler<R> handler = (object, objectResult) -> { PrismProperty<Object> objectProperty = object.findProperty(itemPath); if (objectProperty == null) { return true; } if (isMatching(newPassword, objectProperty)) { if (failAction != null) { failAction.accept(prohibitedItemType); } isAcceptable.setValue(false); return false; } return true; }; originResolver.resolve(handler, prohibitedItemType, shortDesc, task, result); } return isAcceptable.booleanValue(); }
public boolean registerTouchedListener(final IModel<? extends TouchedListener> listener, String... wicketIdPrefixes) { final MutableBoolean changed = new MutableBoolean(false); doWithMatchingModels(new ModelCallback() { @Override public boolean doWithModel(TouchedListenerModelWrapper<?> model) { if (model.registerTouchedListener(listener)) { changed.setValue(true); } return true; } }, wicketIdPrefixes); return changed.booleanValue(); }
public boolean unregisterTouchedListener(final IModel<? extends TouchedListener> listener, String... wicketIdPrefixes) { final MutableBoolean changed = new MutableBoolean(false); doWithMatchingModels(new ModelCallback() { @Override public boolean doWithModel(TouchedListenerModelWrapper<?> model) { if (model.unregisterTouchedListener(listener)) { changed.setValue(true); } return true; } }, wicketIdPrefixes); return changed.booleanValue(); }
@Test(timeout=60000) public void testExpiry() throws Exception { final ShortCircuitCache cache = new ShortCircuitCache(2, 1, 1, 10000000, 1, 10000, 0); final TestFileDescriptorPair pair = new TestFileDescriptorPair(); ShortCircuitReplicaInfo replicaInfo1 = cache.fetchOrCreate( new ExtendedBlockId(123, "test_bp1"), new SimpleReplicaCreator(123, cache, pair)); Preconditions.checkNotNull(replicaInfo1.getReplica()); Preconditions.checkState(replicaInfo1.getInvalidTokenException() == null); pair.compareWith(replicaInfo1.getReplica().getDataStream(), replicaInfo1.getReplica().getMetaStream()); replicaInfo1.getReplica().unref(); final MutableBoolean triedToCreate = new MutableBoolean(false); do { Thread.sleep(10); ShortCircuitReplicaInfo replicaInfo2 = cache.fetchOrCreate( new ExtendedBlockId(123, "test_bp1"), new ShortCircuitReplicaCreator() { @Override public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() { triedToCreate.setValue(true); return null; } }); if ((replicaInfo2 != null) && (replicaInfo2.getReplica() != null)) { replicaInfo2.getReplica().unref(); } } while (triedToCreate.isFalse()); cache.close(); }
/** * Constructor * * @param showRunningScores whether the view is showing the running scores */ public MenuBar(final MutableBoolean showRunningScores) { this.gameExit = new JMenuItem(GAME_EXIT_LABEL); this.gameNew = new JMenuItem(GAME_NEW_LABEL); this.optionsShowRunningScores = new JMenuItem(); add(getGameMenu()); add(getOptionsMenu(showRunningScores)); add(getHelpMenu()); }
/** * Returns the "Options" menu for this menu bar * * @param showRunningScores whether the view is showing the running scores * @return a non-<code>null</code> menu */ private JMenu getOptionsMenu(final MutableBoolean showRunningScores) { final JMenu optionsMenu = new JMenu(OPTIONS_LABEL); optionsMenu.setMnemonic('O'); // Show Running Scores optionsMenu.add(optionsShowRunningScores); setShowRunningScores(showRunningScores.booleanValue()); gameNew.setMnemonic('R'); return optionsMenu; }
private static final byte[] toByteArray(final HttpEntity entity, int maxContent, MutableBoolean trimmed) throws IOException { if (entity == null) return new byte[] {}; final InputStream instream = entity.getContent(); if (instream == null) { return null; } Args.check(entity.getContentLength() <= Integer.MAX_VALUE, "HTTP entity too large to be buffered in memory"); int reportedLength = (int) entity.getContentLength(); // set default size for buffer: 100 KB int bufferInitSize = 102400; if (reportedLength != -1) { bufferInitSize = reportedLength; } // avoid init of too large a buffer when we will trim anyway if (maxContent != -1 && bufferInitSize > maxContent) { bufferInitSize = maxContent; } final ByteArrayBuffer buffer = new ByteArrayBuffer(bufferInitSize); final byte[] tmp = new byte[4096]; int lengthRead; while ((lengthRead = instream.read(tmp)) != -1) { // check whether we need to trim if (maxContent != -1 && buffer.length() + lengthRead > maxContent) { buffer.append(tmp, 0, maxContent - buffer.length()); trimmed.setValue(true); break; } buffer.append(tmp, 0, lengthRead); } return buffer.toByteArray(); }
@Override public boolean getUserConfirmation(final String title, final String message) throws QTasteException { final MutableBoolean confirmed = new MutableBoolean(); try { SwingUtilities.invokeAndWait(() -> { int result = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); confirmed.setValue(result == JOptionPane.YES_OPTION); }); } catch (Exception e) { throw new QTasteException("Error while showing user confirmation dialog", e); } return confirmed.booleanValue(); }
/** * Allocate a new shared memory slot connected to this datanode. * * Must be called with the EndpointShmManager lock held. * * @param peer The peer to use to talk to the DataNode. * @param usedPeer (out param) Will be set to true if we used the peer. * When a peer is used * * @param clientName The client name. * @param blockId The block ID to use. * @return null if the DataNode does not support shared memory * segments, or experienced an error creating the * shm. The shared memory segment itself on success. * @throws IOException If there was an error communicating over the socket. */ Slot allocSlot(DomainPeer peer, MutableBoolean usedPeer, String clientName, ExtendedBlockId blockId) throws IOException { while (true) { if (closed) { if (LOG.isTraceEnabled()) { LOG.trace(this + ": the DfsClientShmManager has been closed."); } return null; } if (disabled) { if (LOG.isTraceEnabled()) { LOG.trace(this + ": shared memory segment access is disabled."); } return null; } // Try to use an existing slot. Slot slot = allocSlotFromExistingShm(blockId); if (slot != null) { return slot; } // There are no free slots. If someone is loading more slots, wait // for that to finish. if (loading) { if (LOG.isTraceEnabled()) { LOG.trace(this + ": waiting for loading to finish..."); } finishedLoading.awaitUninterruptibly(); } else { // Otherwise, load the slot ourselves. loading = true; lock.unlock(); DfsClientShm shm; try { shm = requestNewShm(clientName, peer); if (shm == null) continue; // See #{DfsClientShmManager#domainSocketWatcher} for details // about why we do this before retaking the manager lock. domainSocketWatcher.add(peer.getDomainSocket(), shm); // The DomainPeer is now our responsibility, and should not be // closed by the caller. usedPeer.setValue(true); } finally { lock.lock(); loading = false; finishedLoading.signalAll(); } if (shm.isDisconnected()) { // If the peer closed immediately after the shared memory segment // was created, the DomainSocketWatcher callback might already have // fired and marked the shm as disconnected. In this case, we // obviously don't want to add the SharedMemorySegment to our list // of valid not-full segments. if (LOG.isDebugEnabled()) { LOG.debug(this + ": the UNIX domain socket associated with " + "this short-circuit memory closed before we could make " + "use of the shm."); } } else { notFull.put(shm.getShmId(), shm); } } } }
@Test(timeout=60000) public void testEviction() throws Exception { final ShortCircuitCache cache = new ShortCircuitCache(2, 10000000, 1, 10000000, 1, 10000, 0); final TestFileDescriptorPair pairs[] = new TestFileDescriptorPair[] { new TestFileDescriptorPair(), new TestFileDescriptorPair(), new TestFileDescriptorPair(), }; ShortCircuitReplicaInfo replicaInfos[] = new ShortCircuitReplicaInfo[] { null, null, null }; for (int i = 0; i < pairs.length; i++) { replicaInfos[i] = cache.fetchOrCreate( new ExtendedBlockId(i, "test_bp1"), new SimpleReplicaCreator(i, cache, pairs[i])); Preconditions.checkNotNull(replicaInfos[i].getReplica()); Preconditions.checkState(replicaInfos[i].getInvalidTokenException() == null); pairs[i].compareWith(replicaInfos[i].getReplica().getDataStream(), replicaInfos[i].getReplica().getMetaStream()); } // At this point, we have 3 replicas in use. // Let's close them all. for (int i = 0; i < pairs.length; i++) { replicaInfos[i].getReplica().unref(); } // The last two replicas should still be cached. for (int i = 1; i < pairs.length; i++) { final Integer iVal = new Integer(i); replicaInfos[i] = cache.fetchOrCreate( new ExtendedBlockId(i, "test_bp1"), new ShortCircuitReplicaCreator() { @Override public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() { Assert.fail("expected to use existing entry for " + iVal); return null; } }); Preconditions.checkNotNull(replicaInfos[i].getReplica()); Preconditions.checkState(replicaInfos[i].getInvalidTokenException() == null); pairs[i].compareWith(replicaInfos[i].getReplica().getDataStream(), replicaInfos[i].getReplica().getMetaStream()); } // The first (oldest) replica should not be cached. final MutableBoolean calledCreate = new MutableBoolean(false); replicaInfos[0] = cache.fetchOrCreate( new ExtendedBlockId(0, "test_bp1"), new ShortCircuitReplicaCreator() { @Override public ShortCircuitReplicaInfo createShortCircuitReplicaInfo() { calledCreate.setValue(true); return null; } }); Preconditions.checkState(replicaInfos[0].getReplica() == null); Assert.assertTrue(calledCreate.isTrue()); // Clean up for (int i = 1; i < pairs.length; i++) { replicaInfos[i].getReplica().unref(); } for (int i = 0; i < pairs.length; i++) { pairs[i].close(); } cache.close(); }
@Test public void test() throws IOException, InterruptedException { final HRegionServer rs = testUtil.getRSForFirstRegionInTable(tableName); final HRegion region = (HRegion) rs.getOnlineRegions(tableName).get(0); HRegion spiedRegion = spy(region); final MutableBoolean flushed = new MutableBoolean(false); final MutableBoolean reported = new MutableBoolean(false); doAnswer(new Answer<FlushResult>() { @Override public FlushResult answer(InvocationOnMock invocation) throws Throwable { synchronized (flushed) { flushed.setValue(true); flushed.notifyAll(); } synchronized (reported) { while (!reported.booleanValue()) { reported.wait(); } } rs.getWAL(region.getRegionInfo()).abortCacheFlush( region.getRegionInfo().getEncodedNameAsBytes()); throw new DroppedSnapshotException("testcase"); } }).when(spiedRegion).internalFlushCacheAndCommit(Matchers.<WAL> any(), Matchers.<MonitoredTask> any(), Matchers.<PrepareFlushResult> any(), Matchers.<Collection<Store>> any()); // Find region key; don't pick up key for hbase:meta by mistake. String key = null; for (Map.Entry<String, Region> entry: rs.onlineRegions.entrySet()) { if (entry.getValue().getRegionInfo().getTable().equals(this.tableName)) { key = entry.getKey(); break; } } rs.onlineRegions.put(key, spiedRegion); Connection conn = testUtil.getConnection(); try (Table table = conn.getTable(tableName)) { table.put(new Put(Bytes.toBytes("row0")).addColumn(family, qualifier, Bytes.toBytes("val0"))); } long oldestSeqIdOfStore = region.getOldestSeqIdOfStore(family); LOG.info("CHANGE OLDEST " + oldestSeqIdOfStore); assertTrue(oldestSeqIdOfStore > HConstants.NO_SEQNUM); rs.cacheFlusher.requestFlush(spiedRegion, false); synchronized (flushed) { while (!flushed.booleanValue()) { flushed.wait(); } } try (Table table = conn.getTable(tableName)) { table.put(new Put(Bytes.toBytes("row1")).addColumn(family, qualifier, Bytes.toBytes("val1"))); } long now = EnvironmentEdgeManager.currentTime(); rs.tryRegionServerReport(now - 500, now); synchronized (reported) { reported.setValue(true); reported.notifyAll(); } while (testUtil.getRSForFirstRegionInTable(tableName) == rs) { Thread.sleep(100); } try (Table table = conn.getTable(tableName)) { Result result = table.get(new Get(Bytes.toBytes("row0"))); assertArrayEquals(Bytes.toBytes("val0"), result.getValue(family, qualifier)); } }
/** * Test flush for sure has a sequence id that is beyond the last edit appended. We do this * by slowing appends in the background ring buffer thread while in foreground we call * flush. The addition of the sync over HRegion in flush should fix an issue where flush was * returning before all of its appends had made it out to the WAL (HBASE-11109). * @throws IOException * @see HBASE-11109 */ @Test public void testFlushSequenceIdIsGreaterThanAllEditsInHFile() throws IOException { String testName = "testFlushSequenceIdIsGreaterThanAllEditsInHFile"; final TableName tableName = TableName.valueOf(testName); final HRegionInfo hri = new HRegionInfo(tableName); final byte[] rowName = tableName.getName(); final HTableDescriptor htd = new HTableDescriptor(tableName); htd.addFamily(new HColumnDescriptor("f")); HRegion r = HRegion.createHRegion(hri, TEST_UTIL.getDefaultRootDirPath(), TEST_UTIL.getConfiguration(), htd); HRegion.closeHRegion(r); final int countPerFamily = 10; final MutableBoolean goslow = new MutableBoolean(false); // subclass and doctor a method. FSHLog wal = new FSHLog(FileSystem.get(conf), TEST_UTIL.getDefaultRootDirPath(), testName, conf) { @Override void atHeadOfRingBufferEventHandlerAppend() { if (goslow.isTrue()) { Threads.sleep(100); LOG.debug("Sleeping before appending 100ms"); } super.atHeadOfRingBufferEventHandlerAppend(); } }; HRegion region = HRegion.openHRegion(TEST_UTIL.getConfiguration(), TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath(), hri, htd, wal); EnvironmentEdge ee = EnvironmentEdgeManager.getDelegate(); try { List<Put> puts = null; for (HColumnDescriptor hcd: htd.getFamilies()) { puts = TestWALReplay.addRegionEdits(rowName, hcd.getName(), countPerFamily, ee, region, "x"); } // Now assert edits made it in. final Get g = new Get(rowName); Result result = region.get(g); assertEquals(countPerFamily * htd.getFamilies().size(), result.size()); // Construct a WALEdit and add it a few times to the WAL. WALEdit edits = new WALEdit(); for (Put p: puts) { CellScanner cs = p.cellScanner(); while (cs.advance()) { edits.add(cs.current()); } } // Add any old cluster id. List<UUID> clusterIds = new ArrayList<UUID>(); clusterIds.add(UUID.randomUUID()); // Now make appends run slow. goslow.setValue(true); for (int i = 0; i < countPerFamily; i++) { final HRegionInfo info = region.getRegionInfo(); final WALKey logkey = new WALKey(info.getEncodedNameAsBytes(), tableName, System.currentTimeMillis(), clusterIds, -1, -1, region.getMVCC()); wal.append(htd, info, logkey, edits, true); } region.flush(true); // FlushResult.flushSequenceId is not visible here so go get the current sequence id. long currentSequenceId = region.getSequenceId(); // Now release the appends goslow.setValue(false); synchronized (goslow) { goslow.notifyAll(); } assertTrue(currentSequenceId >= region.getSequenceId()); } finally { region.close(true); wal.close(); } }
public MutableBoolean getCouldNotCommunicateWithServer() { return couldNotCommunicateWithServer; }