本文整理汇总了Java中org.agrona.CloseHelper类的典型用法代码示例。如果您正苦于以下问题:Java CloseHelper类的具体用法?Java CloseHelper怎么用?Java CloseHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloseHelper类属于org.agrona包,在下文中一共展示了CloseHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import org.agrona.CloseHelper; //导入依赖的package包/类
@Override
public void close()
{
CloseHelper.quietClose(reporter);
gatewayList.forEach(CloseHelper::quietClose);
gatewayList.clear();
gatewaySubscriptionRepository.clear();
serviceList.forEach(CloseHelper::quietClose);
serviceList.clear();
serviceSubscriptionRepository.clear();
CloseHelper.quietClose(aeron);
CloseHelper.quietClose(driver);
}
示例2: libraryDetectsEngineDisconnect
import org.agrona.CloseHelper; //导入依赖的package包/类
@Test
public void libraryDetectsEngineDisconnect()
{
library = connectLibrary();
awaitLibraryConnect(library);
CloseHelper.close(engine);
assertEventuallyTrue(
() -> "Engine still hasn't disconnected",
() ->
{
library.poll(5);
return !library.isConnected();
},
AWAIT_TIMEOUT,
() ->
{
}
);
}
示例3: close
import org.agrona.CloseHelper; //导入依赖的package包/类
public synchronized void close(final int libraryId)
{
final Agent agentToRemove = libraryIdToDelegateAgent.remove(libraryId);
if (agentToRemove != null)
{
while (!dynamicAgent.tryRemove(agentToRemove))
{
Thread.yield();
}
while (!dynamicAgent.hasRemoveAgentCompleted())
{
Thread.yield();
}
if (libraryIdToDelegateAgent.isEmpty())
{
CloseHelper.close(runner);
runner = null;
}
}
}
示例4: close
import org.agrona.CloseHelper; //导入依赖的package包/类
/**
* Notify the archive that this control session is closed so it can promptly release resources then close the
* local resources associated with the client.
*/
public void close()
{
lock.lock();
try
{
archiveProxy.closeSession(controlSessionId);
if (!context.ownsAeronClient())
{
CloseHelper.close(controlResponsePoller.subscription());
CloseHelper.close(archiveProxy.publication());
}
CloseHelper.close(context);
}
finally
{
lock.unlock();
}
}
示例5: closeOnError
import org.agrona.CloseHelper; //导入依赖的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);
}
}
示例6: newRecordingSegmentFile
import org.agrona.CloseHelper; //导入依赖的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);
}
}
示例7: close
import org.agrona.CloseHelper; //导入依赖的package包/类
/**
* Close session and release associated resources.
*/
public void close()
{
lock.lock();
try
{
if (publication.isConnected())
{
closeSession();
}
if (!ctx.ownsAeronClient())
{
CloseHelper.close(subscription);
CloseHelper.close(publication);
}
ctx.close();
}
finally
{
lock.unlock();
}
}
示例8: after
import org.agrona.CloseHelper; //导入依赖的package包/类
@After
public void after()
{
CloseHelper.close(aeronCluster);
CloseHelper.close(container);
CloseHelper.close(clusteredMediaDriver);
if (null != container)
{
container.context().deleteDirectory();
}
clusteredMediaDriver.consensusModule().context().deleteDirectory();
clusteredMediaDriver.archive().context().deleteArchiveDirectory();
clusteredMediaDriver.mediaDriver().context().deleteAeronDirectory();
}
示例9: close
import org.agrona.CloseHelper; //导入依赖的package包/类
/**
* Stop the server
* @throws Exception
*/
@Override
public void close() throws Exception {
if (subscriber != null) {
for (int i = 0; i < subscriber.length; i++) {
if (subscriber[i] != null) {
subscriber[i].close();
}
}
}
if (server != null)
server.stop();
if (mediaDriver != null)
CloseHelper.quietClose(mediaDriver);
if (aeron != null)
CloseHelper.quietClose(aeron);
}
示例10: close
import org.agrona.CloseHelper; //导入依赖的package包/类
@Override
public void close() throws Exception
{
writeBatchingBuffer();
journalling.flush();
CloseHelper.quietClose(journalling);
DirectBufferAllocator.free(batchingBuffer);
}
示例11: close
import org.agrona.CloseHelper; //导入依赖的package包/类
@Override
public void close() throws Exception
{
running.set(false);
journallerThread.join();
CloseHelper.quietClose(journalHandler);
}
示例12: close
import org.agrona.CloseHelper; //导入依赖的package包/类
@Override
public void close() throws IOException
{
positionInFile = 0;
journalAllocator.reset();
CloseHelper.close(currentJournal);
currentJournal = null;
}
示例13: roll
import org.agrona.CloseHelper; //导入依赖的package包/类
private void roll() throws IOException
{
CloseHelper.close(currentJournal);
if (lastJournalReached() && handler != null)
{
handler.onJournalDepletion(this);
}
currentJournal = journalAllocator.getNextJournal();
}
示例14: close
import org.agrona.CloseHelper; //导入依赖的package包/类
@Override
public void close() throws Exception
{
CloseHelper.quietClose(journalling);
DirectBufferAllocator.free(readBuffer1.byteBuffer());
DirectBufferAllocator.free(readBuffer2.byteBuffer());
}
示例15: close
import org.agrona.CloseHelper; //导入依赖的package包/类
@Override
public void close()
{
gwInputProcessorList.forEach(CloseHelper::quietClose);
gwOutputProcessorList.forEach(CloseHelper::quietClose);
eventProcessorList.forEach(CloseHelper::quietClose);
gatewayProcessorList.forEach(CloseHelper::quietClose);
}