org.apache.commons.lang3.concurrent.ConcurrentException Java Examples

The following examples show how to use org.apache.commons.lang3.concurrent.ConcurrentException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChunkedDatasetBase.java    From jhdf with MIT License 6 votes vote down vote up
private byte[] decompressChunk(Chunk chunk) {
    // Get the encoded (i.e. compressed buffer)
    final ByteBuffer encodedBuffer = getDataBuffer(chunk);

    // Get the encoded data from buffer
    final byte[] encodedBytes = new byte[encodedBuffer.remaining()];
    encodedBuffer.get(encodedBytes);

    try {
        final FilterPipeline pipeline = this.lazyPipeline.get();

        if (pipeline == null) {
            // No filters
            logger.debug("No filters returning decoded chunk '{}'", chunk);
            return encodedBytes;
        }

        // Decode using the pipeline applying the filters
        final byte[] decodedBytes = pipeline.decode(encodedBytes);
        logger.debug("Decoded {}", chunk);

        return decodedBytes;
    } catch (ConcurrentException e) {
        throw new HdfException("Failed to get filter pipeline", e);
    }
}
 
Example #2
Source File: BuilderMethods.java    From tutorials with MIT License 6 votes vote down vote up
public static void main(final String[] arguments) {
    final BuilderMethods simple1 = new BuilderMethods(1, "The First One");
    System.out.println(simple1.getName());
    System.out.println(simple1.hashCode());
    System.out.println(simple1.toString());

    SampleLazyInitializer sampleLazyInitializer = new SampleLazyInitializer();

    try {
        sampleLazyInitializer.get();
    } catch (ConcurrentException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    SampleBackgroundInitializer sampleBackgroundInitializer = new SampleBackgroundInitializer();
    sampleBackgroundInitializer.start();

    // Proceed with other tasks instead of waiting for the SampleBackgroundInitializer task to finish.

    try {
        Object result = sampleBackgroundInitializer.get();
    } catch (ConcurrentException e) {
        e.printStackTrace();
    }
}
 
Example #3
Source File: ObjectHeaderTest.java    From jhdf with MIT License 6 votes vote down vote up
@Test
void testLazyObjectHeader() throws ConcurrentException, IOException {
	FileChannel spyFc = Mockito.spy(fc);
	HdfFileChannel hdfFileChannel = new HdfFileChannel(spyFc, sb);
	LazyInitializer<ObjectHeader> lazyObjectHeader = ObjectHeader.lazyReadObjectHeader(hdfFileChannel, 10904); // int8
	// header
	// Creating the lazy object header should not touch the file
	Mockito.verifyNoInteractions(spyFc);

	// Get the actual header should cause the file to be read
	lazyObjectHeader.get();

	// Check the file was read
	verify(spyFc, Mockito.atLeastOnce()).read(any(ByteBuffer.class), anyLong());

	// Ensure nothing else was done to the file
	Mockito.verifyNoMoreInteractions(spyFc);
}
 
Example #4
Source File: SegmentRunner.java    From cassandra-reaper with Apache License 2.0 6 votes vote down vote up
private void handlePotentialStuckRepairs(LazyInitializer<Set<String>> busyHosts, String hostName)
    throws ConcurrentException {

  if (!busyHosts.get().contains(hostName) && context.storage instanceof IDistributedStorage) {
    try {
      JmxProxy hostProxy = clusterFacade.connect(context.storage.getCluster(clusterName), Arrays.asList(hostName));

      // We double check that repair is still running there before actually cancelling repairs
      if (hostProxy.isRepairRunning()) {
        LOG.warn(
            "A host ({}) reported that it is involved in a repair, but there is no record "
                + "of any ongoing repair involving the host. Sending command to abort all repairs "
                + "on the host.",
            hostName);
        hostProxy.cancelAllRepairs();
      }
    } catch (ReaperException | RuntimeException | JMException e) {
      LOG.debug("failed to cancel repairs on host {}", hostName, e);
    }
  }
}
 
Example #5
Source File: ChunkedDatasetV4.java    From jhdf with MIT License 5 votes vote down vote up
@Override
protected Map<ChunkOffset, Chunk> getChunkLookup() {
    try {
        return chunkLookupLazyInitializer.get();
    } catch (ConcurrentException e) {
        throw new HdfException("Failed to create chunk lookup for: " + getPath(), e);
    }
}
 
Example #6
Source File: Lang3UtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void ConcurrentExceptionSample() throws ConcurrentException {
    final Error err = new AssertionError("Test");
    try {
        ConcurrentUtils.handleCause(new ExecutionException(err));
        fail("Error not thrown!");
    } catch (final Error e) {
        assertEquals("Wrong error", err, e);
    }
}
 
Example #7
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 5 votes vote down vote up
public static BasicMetaDataImpl getInstance() {
    try {
        return initializer.get();
    } catch (ConcurrentException e) {
        throw new NetSuiteException("Initialization error", e);
    }
}
 
Example #8
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 5 votes vote down vote up
public static BasicMetaDataImpl getInstance() {
    try {
        return initializer.get();
    } catch (ConcurrentException e) {
        throw new NetSuiteException("Initialization error", e);
    }
}
 
Example #9
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 5 votes vote down vote up
public static BasicMetaDataImpl getInstance() {
    try {
        return initializer.get();
    } catch (ConcurrentException e) {
        throw new NetSuiteException("Initialization error", e);
    }
}
 
Example #10
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 5 votes vote down vote up
public static BasicMetaDataImpl getInstance() {
    try {
        return initializer.get();
    } catch (ConcurrentException e) {
        throw new NetSuiteException("Initialization error", e);
    }
}
 
Example #11
Source File: GroupImpl.java    From jhdf with MIT License 5 votes vote down vote up
@Override
protected Map<String, Node> initialize() throws ConcurrentException {
	logger.info("Lazy loading children of '{}'", getPath());

	if (header.get().hasMessageOfType(SymbolTableMessage.class)) {
		// Its an old style Group
		return createOldStyleGroup(header.get());
	} else {
		return createNewStyleGroup(header.get());
	}
}
 
Example #12
Source File: AbstractNode.java    From jhdf with MIT License 5 votes vote down vote up
@Override
protected Map<String, Attribute> initialize() throws ConcurrentException {
	logger.debug("Lazy initializing attributes for '{}'", getPath());
	final ObjectHeader oh = lazyObjectHeader.get();

	List<AttributeMessage> attributeMessages = new ArrayList<>();

	if (oh.hasMessageOfType(AttributeInfoMessage.class)) {
		// Attributes stored in b-tree
		AttributeInfoMessage attributeInfoMessage = oh.getMessageOfType(AttributeInfoMessage.class);

		if (attributeInfoMessage.getFractalHeapAddress() != Constants.UNDEFINED_ADDRESS) {
			// Create the heap and btree
			FractalHeap fractalHeap = new FractalHeap(hdfFc, attributeInfoMessage.getFractalHeapAddress());
			BTreeV2<AttributeNameForIndexedAttributesRecord> btree = new BTreeV2<>(hdfFc,
					attributeInfoMessage.getAttributeNameBTreeAddress());

			// Read the attribute messages from the btree+heap
			for (AttributeNameForIndexedAttributesRecord attributeRecord : btree.getRecords()) {
				ByteBuffer bb = fractalHeap.getId(attributeRecord.getHeapId());
				AttributeMessage attributeMessage = new AttributeMessage(bb, hdfFc.getSuperblock(),
						attributeRecord.getFlags());
				logger.trace("Read attribute message '{}'", attributeMessage);
				attributeMessages.add(attributeMessage);
			}
		}
	}

	// Add the messages stored directly in the header
	attributeMessages.addAll(oh.getMessagesOfType(AttributeMessage.class));

	return attributeMessages.stream()
			.collect(
					toMap(AttributeMessage::getName,
							message -> new AttributeImpl(hdfFc, AbstractNode.this, message)));
}
 
Example #13
Source File: ChunkedDatasetV3.java    From jhdf with MIT License 5 votes vote down vote up
@Override
protected Map<ChunkOffset, Chunk> getChunkLookup() {
    try {
        return chunkLookupLazyInitializer.get();
    } catch (ConcurrentException e) {
        throw new HdfException("Failed to create chunk lookup for: " + getPath(), e);
    }
}
 
Example #14
Source File: KeyStoreFactory.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<KeyStore> getKeyStore()
{
    try
    {
        return cachedKeyStore.get();
    }
    catch (ConcurrentException e)
    {
        throw new IllegalStateException(e);
    }
}
 
Example #15
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 4 votes vote down vote up
@Override protected BasicMetaDataImpl initialize() throws ConcurrentException {
    return new BasicMetaDataImpl();
}
 
Example #16
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 4 votes vote down vote up
@Override protected BasicMetaDataImpl initialize() throws ConcurrentException {
    return new BasicMetaDataImpl();
}
 
Example #17
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 4 votes vote down vote up
@Override protected BasicMetaDataImpl initialize() throws ConcurrentException {
    return new BasicMetaDataImpl();
}
 
Example #18
Source File: BasicMetaDataImpl.java    From components with Apache License 2.0 4 votes vote down vote up
@Override protected BasicMetaDataImpl initialize() throws ConcurrentException {
    return new BasicMetaDataImpl();
}
 
Example #19
Source File: LazyInitializerUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void givenLazyInitializerInstance_whenCalledget_thenCorrect() throws ConcurrentException {
    UserInitializer userInitializer = new UserInitializer();
    assertThat(userInitializer.get()).isInstanceOf(User.class);
}