本文整理了Java中org.agrona.IoUtil.mapNewFile()
方法的一些代码示例,展示了IoUtil.mapNewFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtil.mapNewFile()
方法的具体详情如下:
包路径:org.agrona.IoUtil
类名称:IoUtil
方法名:mapNewFile
[英]Create a new file, fill with 0s, and return a java.nio.MappedByteBuffer for the file.
The file itself will be closed, but the mapping will persist.
[中]创建一个新文件,填充0,然后返回一个java。尼奥。文件的MappedByteBuffer。
文件本身将被关闭,但映射将保持不变。
代码示例来源:origin: real-logic/agrona
/**
* Create a new file, fill with 0s, and return a {@link java.nio.MappedByteBuffer} for the file.
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to create and map
* @param length of the file to create and map
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapNewFile(final File location, final long length)
{
return mapNewFile(location, length, true);
}
代码示例来源:origin: real-logic/aeron
/**
* Map a new loss report in the Aeron directory for a given length.
*
* @param aeronDirectoryName in which to create the file.
* @param reportFileLength for the file.
* @return the newly mapped buffer for the file.
*/
public static MappedByteBuffer mapLossReport(final String aeronDirectoryName, final int reportFileLength)
{
return mapNewFile(file(aeronDirectoryName), reportFileLength, false);
}
}
代码示例来源:origin: real-logic/aeron
private void createFile(final long correlationId, final long length, final String filename)
{
if (fileSessionByIdMap.containsKey(correlationId))
{
throw new IllegalStateException("correlationId is in use: " + correlationId);
}
final File file = new File(storageDir, filename);
if (file.exists() && !file.delete())
{
throw new IllegalStateException("failed to delete existing file: " + file);
}
if (length == 0)
{
try
{
if (!file.createNewFile())
{
throw new IllegalStateException("failed to create " + filename);
}
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
else
{
fileSessionByIdMap.put(correlationId, new UnsafeBuffer(IoUtil.mapNewFile(file, length, false)));
}
}
代码示例来源:origin: real-logic/agrona
this.mappedBuffer = IoUtil.mapNewFile(markFile, totalFileLength);
this.buffer = new UnsafeBuffer(mappedBuffer);
this.versionFieldOffset = versionFieldOffset;
代码示例来源:origin: real-logic/aeron
cncByteBuffer = mapNewFile(
cncFile(),
CncFileDescriptor.computeCncFileLength(
代码示例来源:origin: org.agrona/agrona
/**
* Create a new file, fill with 0s, and return a {@link java.nio.MappedByteBuffer} for the file.
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to create and map
* @param length of the file to create and map
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapNewFile(final File location, final long length)
{
return mapNewFile(location, length, true);
}
代码示例来源:origin: io.aeron/aeron-driver
/**
* Map a new loss report in the Aeron directory for a given length.
*
* @param aeronDirectoryName in which to create the file.
* @param reportFileLength for the file.
* @return the newly mapped buffer for the file.
*/
public static MappedByteBuffer mapLossReport(final String aeronDirectoryName, final int reportFileLength)
{
return mapNewFile(file(aeronDirectoryName), reportFileLength, false);
}
}
代码示例来源:origin: io.aeron/aeron-all
/**
* Map a new loss report in the Aeron directory for a given length.
*
* @param aeronDirectoryName in which to create the file.
* @param reportFileLength for the file.
* @return the newly mapped buffer for the file.
*/
public static MappedByteBuffer mapLossReport(final String aeronDirectoryName, final int reportFileLength)
{
return mapNewFile(file(aeronDirectoryName), reportFileLength, false);
}
}
代码示例来源:origin: real-logic/artio
public static MappedByteBuffer mapNewFile(final File file, final int size)
{
final File parentDir = file.getParentFile();
IoUtil.ensureDirectoryExists(parentDir, parentDir.getAbsolutePath());
return IoUtil.mapNewFile(file, size);
}
代码示例来源:origin: kaazing/gateway
@Override
public void initialize(File monitoringFile) {
int fileSize = computeMonitorTotalFileLength();
mappedMonitorFile = IoUtil.mapNewFile(monitoringFile, fileSize);
metaDataBuffer = new UnsafeBuffer(mappedMonitorFile, 0, metadataLength + BitUtil.SIZE_OF_INT);
fillMetaData();
}
代码示例来源:origin: org.agrona/agrona
this.mappedBuffer = IoUtil.mapNewFile(markFile, totalFileLength);
this.buffer = new UnsafeBuffer(mappedBuffer);
this.versionFieldOffset = versionFieldOffset;
代码示例来源:origin: io.aeron/aeron-all
cncByteBuffer = mapNewFile(
cncFile(),
CncFileDescriptor.computeCncFileLength(
代码示例来源:origin: io.aeron/aeron-driver
cncByteBuffer = mapNewFile(
cncFile(),
CncFileDescriptor.computeCncFileLength(
内容来源于网络,如有侵权,请联系作者删除!