本文整理汇总了Java中org.agrona.LangUtil.rethrowUnchecked方法的典型用法代码示例。如果您正苦于以下问题:Java LangUtil.rethrowUnchecked方法的具体用法?Java LangUtil.rethrowUnchecked怎么用?Java LangUtil.rethrowUnchecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.agrona.LangUtil
的用法示例。
在下文中一共展示了LangUtil.rethrowUnchecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newJournalStrategy
import org.agrona.LangUtil; //导入方法依赖的package包/类
private static Journalling newJournalStrategy(final String journallingClassName)
{
final Path journalDir = Paths.get(JOURNAL_DIR_NAME);
Journalling journalling = null;
if (journallingClassName == null)
{
journalling = new PositionalJournalling(journalDir, JOURNAL_FILE_SIZE, JOURNAL_PAGE_SIZE, JOURNAL_FILE_COUNT);
}
else
{
try
{
journalling = (Journalling)Class.forName(journallingClassName)
.getConstructor(Path.class, Long.class, Integer.class)
.newInstance(journalDir, JOURNAL_FILE_SIZE, JOURNAL_FILE_COUNT);
}
catch (final Exception ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
return journalling;
}
示例2: open
import org.agrona.LangUtil; //导入方法依赖的package包/类
@Override
public Journalling open(final AllocationMode allocationMode)
{
try
{
journalAllocator.preallocate(fileSize, allocationMode);
assignJournal(0);
}
catch (IOException ioe)
{
LangUtil.rethrowUnchecked(ioe);
}
return this;
}
示例3: onMessage
import org.agrona.LangUtil; //导入方法依赖的package包/类
@Override
public void onMessage(int msgTypeId, MutableDirectBuffer buffer, int index, int length)
{
try
{
while (replicaPublication.offer(buffer, index, length) < 0L)
{
idleStrategy.idle(0);
}
UNSAFE.putOrderedLong(this, MSG_REPLICATED_OFFSET, msgReplicated + 1);
UNSAFE.putOrderedLong(this, BYTES_REPLICATED_OFFSET, bytesReplicated + length);
}
catch (Exception ex)
{
LangUtil.rethrowUnchecked(ex);
}
finally
{
while (!nextRingBuffer.write(msgTypeId, buffer, index, length))
{
idleStrategy.idle(0);
}
}
}
示例4: assertFilesEqual
import org.agrona.LangUtil; //导入方法依赖的package包/类
private void assertFilesEqual(
final String logFileDir, final String otherLogFileDir, final String path)
{
final File file = new File(logFileDir, path);
assertTrue(file.getAbsolutePath(), file.exists());
final File otherFile = new File(otherLogFileDir, path);
assertTrue(otherFile.getAbsolutePath(), otherFile.exists());
assertEquals("lengths differ", file.length(), otherFile.length());
try
{
final byte[] bytes = Files.readAllBytes(file.toPath());
final byte[] otherBytes = Files.readAllBytes(otherFile.toPath());
assertArrayEquals("For file: " + path, bytes, otherBytes);
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
示例5: send
import org.agrona.LangUtil; //导入方法依赖的package包/类
private void send(final Encoder encoder)
{
try
{
final long result = encoder.encode(writeAsciiBuffer, OFFSET);
final int offset = Encoder.offset(result);
final int length = Encoder.length(result);
encoder.reset();
writeBuffer.position(offset).limit(offset + length);
final int written = socket.write(writeBuffer);
assertEquals(length, written);
DebugLogger.log(FIX_TEST, "> [" + writeAsciiBuffer.getAscii(OFFSET, length) + "]");
writeBuffer.clear();
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
示例6: map
import org.agrona.LangUtil; //导入方法依赖的package包/类
public static MappedFile map(final File bufferFile, final int size)
{
final FileChannel fileChannel;
try
{
if (bufferFile.exists())
{
// NB: closing RAF or FileChannel closes them both
fileChannel = new RandomAccessFile(bufferFile, "rw").getChannel();
}
else
{
fileChannel = IoUtil.createEmptyFile(bufferFile, (long)size);
}
final MappedByteBuffer mappedBuffer = fileChannel.map(READ_WRITE, 0, fileChannel.size());
return new MappedFile(bufferFile, fileChannel, new UnsafeBuffer(mappedBuffer));
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
return null;
}
}
示例7: TcpChannelSupplier
import org.agrona.LangUtil; //导入方法依赖的package包/类
public TcpChannelSupplier(final EngineConfiguration configuration)
{
final boolean hasBindAddress = configuration.hasBindAddress();
this.configuration = configuration;
try
{
selector = Selector.open();
if (hasBindAddress)
{
listeningChannel = ServerSocketChannel.open();
listeningChannel.bind(configuration.bindAddress()).configureBlocking(false);
listeningChannel.register(selector, SelectionKey.OP_ACCEPT);
}
else
{
listeningChannel = null;
}
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
示例8: data
import org.agrona.LangUtil; //导入方法依赖的package包/类
@Parameterized.Parameters(name = "Acceptance: {1}")
public static Collection<Object[]> data()
{
try
{
final List<Object[]> tests = new ArrayList<>();
tests.addAll(fix42Tests());
tests.addAll(fix42CustomisedTests());
return tests;
}
catch (Exception e)
{
LangUtil.rethrowUnchecked(e);
return null;
}
}
示例9: resetSessionIds
import org.agrona.LangUtil; //导入方法依赖的package包/类
public Reply<?> resetSessionIds(final File backupLocation, final IdleStrategy idleStrategy)
{
if (backupLocation != null && !backupLocation.exists())
{
try
{
if (!backupLocation.createNewFile())
{
throw new IllegalStateException("Could not create: " + backupLocation);
}
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
final ResetSessionIdsCommand command = new ResetSessionIdsCommand(backupLocation);
if (adminCommands.offer(command))
{
return command;
}
return null;
}
示例10: record
import org.agrona.LangUtil; //导入方法依赖的package包/类
private int record()
{
int workCount = 1;
try
{
workCount = image.rawPoll(recordingWriter, blockLengthLimit);
if (0 != workCount)
{
recordingEventsProxy.progress(recordingId, image.joinPosition(), position.getWeak());
}
if (image.isClosed() || recordingWriter.isClosed())
{
abort();
}
}
catch (final Exception ex)
{
abort();
LangUtil.rethrowUnchecked(ex);
}
return workCount;
}
示例11: closeOnError
import org.agrona.LangUtil; //导入方法依赖的package包/类
private void closeOnError(final Throwable ex, final String errorMessage)
{
state = State.INACTIVE;
CloseHelper.quietClose(replayPublication);
if (null != cursor)
{
cursor.close();
}
if (!controlSession.isDone())
{
controlSession.sendResponse(
correlationId,
ControlResponseCode.ERROR,
errorMessage,
threadLocalControlResponseProxy);
}
if (ex != null)
{
LangUtil.rethrowUnchecked(ex);
}
}
示例12: newRecordingSegmentFile
import org.agrona.LangUtil; //导入方法依赖的package包/类
private void newRecordingSegmentFile()
{
final File file = new File(archiveDir, segmentFileName(recordingId, segmentIndex));
RandomAccessFile recordingFile = null;
try
{
recordingFile = new RandomAccessFile(file, "rw");
recordingFile.setLength(segmentFileLength + DataHeaderFlyweight.HEADER_LENGTH);
recordingFileChannel = recordingFile.getChannel();
if (forceWrites && null != archiveDirChannel)
{
archiveDirChannel.force(forceMetadata);
}
}
catch (final IOException ex)
{
CloseHelper.quietClose(recordingFile);
close();
LangUtil.rethrowUnchecked(ex);
}
}
示例13: allocate
import org.agrona.LangUtil; //导入方法依赖的package包/类
/**
* Allocate a new counter with a given label and type.
*
* @param label to describe the counter.
* @param typeId for the type of counter.
* @return the id allocated for the counter.
*/
public int allocate(final String label, final int typeId)
{
final int counterId = nextCounterId();
checkCountersCapacity(counterId);
final int recordOffset = metaDataOffset(counterId);
checkMetaDataCapacity(recordOffset);
try
{
metaDataBuffer.putInt(recordOffset + TYPE_ID_OFFSET, typeId);
metaDataBuffer.putLong(recordOffset + FREE_FOR_REUSE_DEADLINE_OFFSET, NOT_FREE_TO_REUSE);
putLabel(recordOffset, label);
metaDataBuffer.putIntOrdered(recordOffset, RECORD_ALLOCATED);
}
catch (final Exception ex)
{
freeList.pushInt(counterId);
LangUtil.rethrowUnchecked(ex);
}
return counterId;
}
示例14: write
import org.agrona.LangUtil; //导入方法依赖的package包/类
private void write(final ByteBuffer buffer, final int length)
{
buffer.position(0);
buffer.limit(length);
if (channel != null)
{
try
{
channel.write(buffer);
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
else if (resultBuffer != null)
{
resultBuffer.put(buffer);
}
totalLength += length;
}
示例15: encodeFrame
import org.agrona.LangUtil; //导入方法依赖的package包/类
private int encodeFrame()
{
frameEncoder
.wrap(directBuffer, 0)
.irId(ir.id())
.irVersion(0)
.schemaVersion(ir.version());
try
{
final byte[] packageBytes = ir.packageName().getBytes(packageNameCharacterEncoding());
frameEncoder.putPackageName(packageBytes, 0, packageBytes.length);
final byte[] namespaceBytes = getBytes(ir.namespaceName(), namespaceNameCharacterEncoding());
frameEncoder.putNamespaceName(namespaceBytes, 0, namespaceBytes.length);
final byte[] semanticVersionBytes = getBytes(ir.semanticVersion(), semanticVersionCharacterEncoding());
frameEncoder.putSemanticVersion(semanticVersionBytes, 0, semanticVersionBytes.length);
}
catch (final UnsupportedEncodingException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return frameEncoder.encodedLength();
}