Search in sources :

Example 1 with KafkaLogService

use of com.alibaba.graphscope.groot.wal.kafka.KafkaLogService in project GraphScope by alibaba.

the class KafkaWalTest method testDoubleInit.

@Test
void testDoubleInit() {
    Configs configs = Configs.newBuilder().put(KafkaConfig.KAFKA_SERVERS.getKey(), sharedKafkaTestResource.getKafkaConnectString()).put(KafkaConfig.KAKFA_TOPIC.getKey(), "test_double_init").put(CommonConfig.INGESTOR_QUEUE_COUNT.getKey(), "1").build();
    LogService logService = new KafkaLogService(configs);
    logService.init();
    assertThrows(Exception.class, () -> logService.init());
    logService.destroy();
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) LogService(com.alibaba.graphscope.groot.wal.LogService) Test(org.junit.jupiter.api.Test)

Example 2 with KafkaLogService

use of com.alibaba.graphscope.groot.wal.kafka.KafkaLogService in project GraphScope by alibaba.

the class KafkaWalTest method testLogService.

@Test
void testLogService() throws IOException {
    Configs configs = Configs.newBuilder().put(KafkaConfig.KAFKA_SERVERS.getKey(), sharedKafkaTestResource.getKafkaConnectString()).put(KafkaConfig.KAKFA_TOPIC.getKey(), "test_logservice").put(CommonConfig.INGESTOR_QUEUE_COUNT.getKey(), "1").build();
    LogService logService = new KafkaLogService(configs);
    logService.init();
    int queueId = 0;
    long snapshotId = 1L;
    LogWriter writer = logService.createWriter(queueId);
    LogEntry logEntry = new LogEntry(snapshotId, OperationBatch.newBuilder().addOperationBlob(OperationBlob.MARKER_OPERATION_BLOB).build());
    assertEquals(writer.append(logEntry), 0);
    LogReader reader = logService.createReader(queueId, 0);
    ReadLogEntry readLogEntry = reader.readNext();
    reader.close();
    assertAll(() -> assertEquals(readLogEntry.getOffset(), 0), () -> assertEquals(readLogEntry.getLogEntry().getSnapshotId(), snapshotId));
    OperationBatch operationBatch = readLogEntry.getLogEntry().getOperationBatch();
    assertEquals(operationBatch.getOperationCount(), 1);
    assertEquals(operationBatch.getOperationBlob(0), OperationBlob.MARKER_OPERATION_BLOB);
    assertEquals(writer.append(logEntry), 1);
    assertEquals(writer.append(logEntry), 2);
    assertEquals(writer.append(logEntry), 3);
    LogReader readerTail = logService.createReader(queueId, 4);
    assertNull(readerTail.readNext());
    readerTail.close();
    assertThrows(IllegalArgumentException.class, () -> logService.createReader(queueId, 5));
    logService.deleteBeforeOffset(queueId, 2);
    assertThrows(IllegalArgumentException.class, () -> logService.createReader(queueId, 1));
    writer.close();
    logService.destroy();
}
Also used : ReadLogEntry(com.alibaba.graphscope.groot.wal.ReadLogEntry) LogWriter(com.alibaba.graphscope.groot.wal.LogWriter) Configs(com.alibaba.maxgraph.common.config.Configs) LogReader(com.alibaba.graphscope.groot.wal.LogReader) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) LogService(com.alibaba.graphscope.groot.wal.LogService) LogEntry(com.alibaba.graphscope.groot.wal.LogEntry) ReadLogEntry(com.alibaba.graphscope.groot.wal.ReadLogEntry) OperationBatch(com.alibaba.graphscope.groot.operation.OperationBatch) Test(org.junit.jupiter.api.Test)

Example 3 with KafkaLogService

use of com.alibaba.graphscope.groot.wal.kafka.KafkaLogService in project GraphScope by alibaba.

the class KafkaWalTest method testDoubleDestroy.

@Test
void testDoubleDestroy() {
    Configs configs = Configs.newBuilder().put(KafkaConfig.KAFKA_SERVERS.getKey(), sharedKafkaTestResource.getKafkaConnectString()).put(KafkaConfig.KAKFA_TOPIC.getKey(), "test_double_destroy").put(CommonConfig.INGESTOR_QUEUE_COUNT.getKey(), "1").build();
    LogService logService = new KafkaLogService(configs);
    logService.init();
    logService.destroy();
    assertThrows(Exception.class, () -> logService.destroy());
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) KafkaLogService(com.alibaba.graphscope.groot.wal.kafka.KafkaLogService) LogService(com.alibaba.graphscope.groot.wal.LogService) Test(org.junit.jupiter.api.Test)

Aggregations

LogService (com.alibaba.graphscope.groot.wal.LogService)3 KafkaLogService (com.alibaba.graphscope.groot.wal.kafka.KafkaLogService)3 Configs (com.alibaba.maxgraph.common.config.Configs)3 Test (org.junit.jupiter.api.Test)3 OperationBatch (com.alibaba.graphscope.groot.operation.OperationBatch)1 LogEntry (com.alibaba.graphscope.groot.wal.LogEntry)1 LogReader (com.alibaba.graphscope.groot.wal.LogReader)1 LogWriter (com.alibaba.graphscope.groot.wal.LogWriter)1 ReadLogEntry (com.alibaba.graphscope.groot.wal.ReadLogEntry)1