• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LangUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.agrona.LangUtil的典型用法代码示例。如果您正苦于以下问题:Java LangUtil类的具体用法?Java LangUtil怎么用?Java LangUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LangUtil类属于org.agrona包,在下文中一共展示了LangUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:canepat,项目名称:Helios,代码行数:27,代码来源:HeliosConfiguration.java


示例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;
}
 
开发者ID:canepat,项目名称:Helios,代码行数:17,代码来源:AbstractJournalling.java


示例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);
        }
    }
}
 
开发者ID:canepat,项目名称:Helios,代码行数:26,代码来源:ReplicaHandler.java


示例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);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:24,代码来源:ClusteredGatewaySystemTest.java


示例5: readMessage

import org.agrona.LangUtil; //导入依赖的package包/类
void readMessage(final Decoder decoder)
{
    final ByteBuffer buffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
    final MutableAsciiBuffer asciiBuffer = new MutableAsciiBuffer(buffer);

    try
    {
        final int read = socket.read(buffer);
        DebugLogger.log(FIX_TEST, "< [" + asciiBuffer.getAscii(OFFSET, read) + "]");
        decoder.decode(asciiBuffer, OFFSET, read);
    }
    catch (final IOException ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:17,代码来源:FixConnection.java


示例6: 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);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:20,代码来源:FixConnection.java


示例7: 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;
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:25,代码来源:MappedFile.java


示例8: 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);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:26,代码来源:TcpChannelSupplier.java


示例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;
}
 
开发者ID:real-logic,项目名称:artio,代码行数:26,代码来源:FramerContext.java


示例10: endpointBufferUpdatedWith

import org.agrona.LangUtil; //导入依赖的package包/类
private void endpointBufferUpdatedWith(final ToIntFunction<ByteBuffer> bufferUpdater)
{
    try
    {
        doAnswer(
            (invocation) ->
            {
                final ByteBuffer buffer = (ByteBuffer)invocation.getArguments()[0];
                return bufferUpdater.applyAsInt(buffer);
            }).when(mockChannel).read(any(ByteBuffer.class));
    }
    catch (final IOException ex)
    {
        // Should never happen, test in error
        LangUtil.rethrowUnchecked(ex);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:18,代码来源:ReceiverEndPointTest.java


示例11: 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;
    }
}
 
开发者ID:real-logic,项目名称:fix-integration,代码行数:17,代码来源:Fix42SpecAcceptanceTest.java


示例12: onMessage

import org.agrona.LangUtil; //导入依赖的package包/类
private void onMessage(final Message message, final SessionID sessionID)
{
    messages.add(message);
    try
    {
        final String msgType = message.getHeader().getField(new MsgType()).getValue();
        if (MsgType.LOGOUT.equals(msgType))
        {
            logouts.add(sessionID);
        }
    }
    catch (FieldNotFound fieldNotFound)
    {
        LangUtil.rethrowUnchecked(fieldNotFound);
    }
}
 
开发者ID:real-logic,项目名称:fix-integration,代码行数:17,代码来源:FakeQuickFixApplication.java


示例13: 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;
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:25,代码来源:RecordingSession.java


示例14: 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);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:25,代码来源:ReplaySession.java


示例15: 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);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:23,代码来源:RecordingWriter.java


示例16: receive

import org.agrona.LangUtil; //导入依赖的package包/类
/**
 * Receive a datagram from the media layer.
 *
 * @param buffer into which the datagram will be received.
 * @return the source address of the datagram if one is available otherwise false.
 */
public InetSocketAddress receive(final ByteBuffer buffer)
{
    buffer.clear();

    InetSocketAddress address = null;
    try
    {
        address = (InetSocketAddress)receiveDatagramChannel.receive(buffer);
    }
    catch (final PortUnreachableException | ClosedChannelException ignored)
    {
        // do nothing
    }
    catch (final Exception ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }

    return address;
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:27,代码来源:UdpChannelTransport.java


示例17: sendTo

import org.agrona.LangUtil; //导入依赖的package包/类
/**
 * Send contents of {@link java.nio.ByteBuffer} to remote address
 *
 * @param buffer        to send
 * @param remoteAddress to send to
 * @return number of bytes sent
 */
public int sendTo(final ByteBuffer buffer, final InetSocketAddress remoteAddress)
{
    int bytesSent = 0;
    try
    {
        if (null != sendDatagramChannel)
        {
            bytesSent = sendDatagramChannel.send(buffer, remoteAddress);
        }
    }
    catch (final IOException ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }

    return bytesSent;
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:25,代码来源:ReceiveChannelEndpoint.java


示例18: newNetworkInterface

import org.agrona.LangUtil; //导入依赖的package包/类
private static NetworkInterface newNetworkInterface(final String name)
{
    NetworkInterface networkInterface = null;
    try
    {
        final Constructor<NetworkInterface> ctor = NetworkInterface.class.getDeclaredConstructor();
        ctor.setAccessible(true);
        final Field nameField = NetworkInterface.class.getDeclaredField("name");
        nameField.setAccessible(true);

        networkInterface = ctor.newInstance();
        nameField.set(networkInterface, name);

    }
    catch (final Exception ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }

    return networkInterface;
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:22,代码来源:NetworkUtilTest.java


示例19: newInterfaceAddress

import org.agrona.LangUtil; //导入依赖的package包/类
private static InterfaceAddress newInterfaceAddress(final InetAddress inetAddress, final short maskLength)
{
    InterfaceAddress interfaceAddress = null;
    try
    {
        final Constructor<InterfaceAddress> ctor = InterfaceAddress.class.getDeclaredConstructor();
        ctor.setAccessible(true);
        final Field addressField = InterfaceAddress.class.getDeclaredField("address");
        addressField.setAccessible(true);
        final Field maskLengthField = InterfaceAddress.class.getDeclaredField("maskLength");
        maskLengthField.setAccessible(true);

        interfaceAddress = ctor.newInstance();
        addressField.set(interfaceAddress, inetAddress);
        maskLengthField.set(interfaceAddress, maskLength);
    }
    catch (final Exception ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }

    return interfaceAddress;
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:24,代码来源:NetworkUtilTest.java


示例20: 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;
}
 
开发者ID:real-logic,项目名称:agrona,代码行数:32,代码来源:CountersManager.java



注:本文中的org.agrona.LangUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApiFuture类代码示例发布时间:2022-05-23
下一篇:
Java Resource类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap