本文整理汇总了Java中com.leansoft.bigqueue.BigArrayImpl类的典型用法代码示例。如果您正苦于以下问题:Java BigArrayImpl类的具体用法?Java BigArrayImpl怎么用?Java BigArrayImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BigArrayImpl类属于com.leansoft.bigqueue包,在下文中一共展示了BigArrayImpl类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTimeBasedFlush
import com.leansoft.bigqueue.BigArrayImpl; //导入依赖的package包/类
@Test
public void testTimeBasedFlush() throws IOException {
this.tearDown();
Properties props = TestUtils.createBrokerConfig(0, -1);
props.setProperty("log.backfile.page.size", String.valueOf(BigArrayImpl.MINIMUM_DATA_PAGE_SIZE));
props.setProperty("topic.flush.intervals.ms", "timebasedflush:200");
props.setProperty("log.default.flush.scheduler.interval.ms", "50");
ServerConfig config = new ServerConfig(props);
logManager = new LogManager(config, null, -1, maxLogAge, false, null);
logManager.startup();
logDir = logManager.logDir;
Log log = (Log) logManager.getOrCreateLog("timebasedflush");
String randomString = TestUtils.randomString(32);
for(int i = 0; i < 1024 * 1024; i++) {
log.append(randomString.getBytes());
}
assertTrue(System.currentTimeMillis() - log.getLastFlushedTime() <= 1000);
}
示例2: setUp
import com.leansoft.bigqueue.BigArrayImpl; //导入依赖的package包/类
@Before
public void setUp() {
Properties props = TestUtils.createBrokerConfig(0, -1);
props.setProperty("log.backfile.page.size", String.valueOf(BigArrayImpl.MINIMUM_DATA_PAGE_SIZE));
config = new ServerConfig(props);
logManager = new LogManager(config, null, -1, maxLogAge, false, null);
logManager.startup();
logDir = logManager.logDir;
}
示例3: testCleanupLogPageFilesToMaintainSize
import com.leansoft.bigqueue.BigArrayImpl; //导入依赖的package包/类
@Test
public void testCleanupLogPageFilesToMaintainSize() throws IOException {
int retentionHours = 1;
long retentionMs = 1000 * 60 * 60 * retentionHours;
this.tearDown();
Properties props = TestUtils.createBrokerConfig(0, -1);
props.setProperty("log.backfile.page.size", String.valueOf(BigArrayImpl.MINIMUM_DATA_PAGE_SIZE));
props.setProperty("log.retention.size", String.valueOf(BigArrayImpl.MINIMUM_DATA_PAGE_SIZE * 3 * 2));// the size of index file should also be taken into account
config = new ServerConfig(props);
logManager = new LogManager(config, null, -1, retentionMs, false, null);
logManager.startup();
logDir = logManager.logDir;
ILog log = logManager.getOrCreateLog("cleanup");
String randomString = TestUtils.randomString(32);
for(int i = 0; i < 4 * 1024 * 1024; i++) { // generate 4 back pages, size of per page = 32M
log.append(randomString.getBytes());
}
log.read(0); // ok
assertTrue(log.getNumberOfBackFiles() == 4);
// let logs expire
TestUtils.sleepQuietly(2000);
// this cleanup shouldn't find any expired segments but should delete some to reduce size
logManager.cleanupLogs();
assertTrue(log.getNumberOfBackFiles() == 3);
try {
log.read(0); // corresponding log page has been deleted
} catch (IndexOutOfBoundsException ex) {
// expected
}
// log should still be appendable
log.append(randomString.getBytes());
}
示例4: FileBlockingQueue
import com.leansoft.bigqueue.BigArrayImpl; //导入依赖的package包/类
public FileBlockingQueue(
String path,
String name,
int gcPeriodInSec,
SerDe<E> serDe,
long sizeLimit) throws IOException {
innerArray = new BigArrayImpl(path, name);
// the ttl does not matter here since queue front index page is always cached
this.queueFrontIndexPageFactory = new MappedPageFactoryImpl(QUEUE_FRONT_INDEX_PAGE_SIZE,
((BigArrayImpl)innerArray).getArrayDirectory() + QUEUE_FRONT_INDEX_PAGE_FOLDER,
10 * 1000/*does not matter*/);
IMappedPage queueFrontIndexPage = this.queueFrontIndexPageFactory.acquirePage(QUEUE_FRONT_PAGE_INDEX);
ByteBuffer queueFrontIndexBuffer = queueFrontIndexPage.getLocal(0);
queueFrontIndex.set(queueFrontIndexBuffer.getLong());
Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
gc();
} catch (Exception e) {
log.error("Exception while gc: " + e.getMessage(), e);
}
}
}, gcPeriodInSec, gcPeriodInSec, TimeUnit.SECONDS);
this.serDe = serDe;
this.sizeLimit = sizeLimit;
}
示例5: getLogPageSize
import com.leansoft.bigqueue.BigArrayImpl; //导入依赖的package包/类
/**
* size per page of back log file
*
* @return size per page
*/
public int getLogPageSize() {
return getIntInRange(props, "log.backfile.page.size", BigArrayImpl.DEFAULT_DATA_PAGE_SIZE, BigArrayImpl.MINIMUM_DATA_PAGE_SIZE, Integer.MAX_VALUE);
}