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

Java StorageLevel类代码示例

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

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



StorageLevel类属于io.atomix.copycat.server.storage包,在下文中一共展示了StorageLevel类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildServer

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
private CopycatServer buildServer() {
    CopycatServer server = CopycatServer.builder(localAddress)
            .withName("partition-" + partition.getId())
            .withSerializer(serializer.clone())
            .withTransport(transport.get())
            .withStateMachine(ResourceManagerState::new)
            .withStorage(Storage.builder()
                    .withStorageLevel(StorageLevel.DISK)
                    .withCompactionThreads(1)
                    .withDirectory(dataFolder)
                    .withMaxEntriesPerSegment(MAX_ENTRIES_PER_LOG_SEGMENT)
                    .build())
            .build();
    server.serializer().resolve(new ResourceManagerTypeResolver());
    return server;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:StoragePartitionServer.java


示例2: createCopycatServer

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
/**
 * Creates a Copycat server.
 */
protected CopycatServer createCopycatServer(Address address) {
    CopycatServer server = CopycatServer.builder(address)
            .withTransport(new LocalTransport(registry))
            .withStorage(Storage.builder()
                    .withStorageLevel(StorageLevel.DISK)
                    .withDirectory(TEST_DIR + "/" + address.port())
                    .build())
            .withStateMachine(ResourceManagerState::new)
            .withSerializer(serializer.clone())
            .withHeartbeatInterval(Duration.ofMillis(25))
            .withElectionTimeout(Duration.ofMillis(50))
            .withSessionTimeout(Duration.ofMillis(100))
            .build();
    copycatServers.add(server);
    return server;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:AtomixTestBase.java


示例3: createCopycatServer

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
@Override
protected CopycatServer createCopycatServer(Address address) {
    CopycatServer server = CopycatServer.builder(address)
            .withTransport(new LocalTransport(registry))
            .withStorage(Storage.builder()
                                 .withStorageLevel(StorageLevel.MEMORY)
                                 .withDirectory(testDir + "/" + address.port())
                                 .build())
            .withStateMachine(ResourceManagerState::new)
            .withSerializer(serializer.clone())
            .withHeartbeatInterval(Duration.ofMillis(25))
            .withElectionTimeout(Duration.ofMillis(50))
            .withSessionTimeout(Duration.ofMillis(100))
            .build();
    copycatServers.add(server);
    return server;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:AsyncConsistentSetMultimapTest.java


示例4: createStateMachine

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
@BeforeMethod
public void createStateMachine() throws Throwable {
  Serializer serializer = new Serializer().resolve(
    new ClientRequestTypeResolver(),
    new ClientResponseTypeResolver(),
    new ProtocolSerialization(),
    new ServerSerialization(),
    new StorageSerialization()
  ).disableWhitelist();

  callerContext = new SingleThreadContext("caller", serializer.clone());
  stateContext = new SingleThreadContext("state", serializer.clone());
  LocalServerRegistry registry = new LocalServerRegistry();
  transport = new LocalTransport(registry);
  Storage storage = new Storage(StorageLevel.MEMORY);
  ServerMember member = new ServerMember(Member.Type.ACTIVE, new Address("localhost", 5000), new Address("localhost", 6000), Instant.now());

  new SingleThreadContext("test", serializer.clone()).executor().execute(() -> {
    state = new ServerContext("test", member.type(), member.serverAddress(), member.clientAddress(), storage, serializer, TestStateMachine::new, new ConnectionManager(new LocalTransport(registry).client()), callerContext);
    resume();
  });
  await(1000);
  timestamp = System.currentTimeMillis();
  sequence = new AtomicLong();
}
 
开发者ID:atomix,项目名称:copycat,代码行数:26,代码来源:ServerStateMachineTest.java


示例5: createServer

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
/**
 * Creates a Copycat server.
 */
private CopycatServer createServer(Member member) {
  CopycatServer.Builder builder = CopycatServer.builder(member.clientAddress(), member.serverAddress())
    .withType(member.type())
    .withTransport(new NettyTransport())
    .withStorage(Storage.builder()
      .withStorageLevel(StorageLevel.DISK)
      .withDirectory(new File(String.format("target/fuzz-logs/%d", member.address().hashCode())))
      .withMaxSegmentSize(randomNumber(1024 * 1024 * 7) + (1024 * 1024))
      .withMaxEntriesPerSegment(randomNumber(10000) + 1000)
      .withCompactionThreads(randomNumber(4) + 1)
      .withCompactionThreshold(Math.random() / (double) 2)
      .withEntryBufferSize(randomNumber(10000) + 1)
      .withFlushOnCommit(randomBoolean())
      .withMinorCompactionInterval(Duration.ofSeconds(randomNumber(30) + 15))
      .withMajorCompactionInterval(Duration.ofSeconds(randomNumber(60) + 60))
      .build())
    .withStateMachine(FuzzStateMachine::new);

  CopycatServer server = builder.build();
  server.serializer().disableWhitelist();
  servers.add(server);
  return server;
}
 
开发者ID:atomix,项目名称:copycat,代码行数:27,代码来源:FuzzTest.java


示例6: createServer

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
/**
 * Creates a Copycat server.
 */
private CopycatServer createServer(Member member) {
  CopycatServer.Builder builder = CopycatServer.builder(member.clientAddress(), member.serverAddress())
    .withType(member.type())
    .withTransport(new NettyTransport())
    .withStorage(Storage.builder()
      .withStorageLevel(StorageLevel.DISK)
      .withDirectory(new File(String.format("target/performance-logs/%d", member.address().hashCode())))
      .withCompactionThreads(1)
      .build())
    .withStateMachine(PerformanceStateMachine::new);

  CopycatServer server = builder.build();
  server.serializer().disableWhitelist();
  servers.add(server);
  return server;
}
 
开发者ID:atomix,项目名称:copycat,代码行数:20,代码来源:PerformanceTest.java


示例7: createServer

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
/**
 * Creates a Copycat server.
 */
private CopycatServer createServer(Member member) {
  CopycatServer.Builder builder = CopycatServer.builder(member.clientAddress(), member.serverAddress())
    .withType(member.type())
    .withTransport(new LocalTransport(registry))
    .withStorage(Storage.builder()
      .withStorageLevel(StorageLevel.MEMORY)
      .withMaxSegmentSize(1024 * 1024)
      .withCompactionThreads(1)
      .build())
    .withStateMachine(TestStateMachine::new);

  CopycatServer server = builder.build();
  server.serializer().disableWhitelist();
  servers.add(server);
  return server;
}
 
开发者ID:atomix,项目名称:copycat,代码行数:20,代码来源:ClusterTest.java


示例8: createSnapshot

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
/**
 * Creates a new snapshot buffer.
 */
private Snapshot createSnapshot(SnapshotDescriptor descriptor) {
  if (storage.level() == StorageLevel.MEMORY) {
    return createMemorySnapshot(descriptor);
  } else {
    return createDiskSnapshot(descriptor);
  }
}
 
开发者ID:atomix,项目名称:copycat,代码行数:11,代码来源:SnapshotStore.java


示例9: MetaStore

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
public MetaStore(String name, Storage storage, Serializer serializer) {
  this.storage = Assert.notNull(storage, "storage");
  this.serializer = Assert.notNull(serializer, "serializer");

  Assert.notNull(storage.directory(), "null storage directory");
  if (!(storage.directory().isDirectory() || storage.directory().mkdirs())) {
    throw new IllegalArgumentException(String.format("Can't create storage directory [%s].", storage.directory()));
  }

  // Note that for raft safety, irrespective of the storage level, <term, vote> metadata is always persisted on disk.
  File metaFile = new File(storage.directory(), String.format("%s.meta", name));
  FileBuffer tmpMetadataBuffer = FileBuffer.allocate(metaFile, 12);

  if (storage.level() == StorageLevel.MEMORY) {
    configurationBuffer = HeapBuffer.allocate(32);
  } else {
    File confFile = new File(storage.directory(), String.format("%s.conf", name));
    configurationBuffer = FileBuffer.allocate(confFile, 32);

    //Note: backward compatibility with pre 1.2.6 release. This can be removed in later releases.
    Configuration configuration = loadConfiguration();
    if (configuration == null) {
      configuration = loadConfigurationFromMetadataBuffer(tmpMetadataBuffer);
      if (configuration != null) {
        storeConfiguration(configuration);
        tmpMetadataBuffer = deleteConfigurationFromMetadataBuffer(metaFile, tmpMetadataBuffer);
      }
    }
  }

  metadataBuffer = tmpMetadataBuffer;
}
 
开发者ID:atomix,项目名称:copycat,代码行数:33,代码来源:MetaStore.java


示例10: beforeMethod

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
/**
 * Sets up a server state.
 */
@BeforeMethod
void beforeMethod() throws Throwable {
  serializer = new Serializer();
  serializer.resolve(
    new ClientRequestTypeResolver(),
    new ClientResponseTypeResolver(),
    new ProtocolSerialization(),
    new ServerSerialization(),
    new StorageSerialization()
  ).disableWhitelist();

  storageDir = Files.createTempDirectory("copycat-test");
  storage = Storage.builder().withStorageLevel(StorageLevel.MEMORY).withDirectory(storageDir.toFile()).build();

  members = createMembers(3);
  transport = new LocalTransport(new LocalServerRegistry());

  serverCtx = new SingleThreadContext("test-server", serializer);
  new SingleThreadContext("test", serializer.clone()).executor().execute(() -> {
    serverContext = new ServerContext("test", members.get(0).type(), members.get(0).serverAddress(), members.get(0).clientAddress(), storage, serializer, TestStateMachine::new, new ConnectionManager(transport.client()), serverCtx);
    serverContext.getThreadContext().executor().execute(() -> {
      serverContext.getClusterState().configure(new Configuration(0, 0, Instant.now().toEpochMilli(), members));
      resume();
    });
  });
  await(1000);
}
 
开发者ID:atomix,项目名称:copycat,代码行数:31,代码来源:AbstractStateTest.java


示例11: configureMemoryOnlyStorage

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
public static void configureMemoryOnlyStorage(ConsensusServer server) {
  server.setConsensusStorageProvider(new ConsensusStorageProvider(null) {
    @Override
    public Storage createStorage() {
      return Storage.builder().withStorageLevel(StorageLevel.MEMORY).build();
    }
  });
}
 
开发者ID:diqube,项目名称:diqube,代码行数:9,代码来源:ConsensusServerTestUtil.java


示例12: createStorage

import io.atomix.copycat.server.storage.StorageLevel; //导入依赖的package包/类
public Storage createStorage() {
  return Storage.builder().withStorageLevel(StorageLevel.DISK).withDirectory(consensusDataDirFile).build();
}
 
开发者ID:diqube,项目名称:diqube,代码行数:4,代码来源:ConsensusServer.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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