当前位置: 首页>>代码示例>>Java>>正文


Java Storage类代码示例

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


Storage类属于de.flapdoodle.embed.mongo.config包,在下文中一共展示了Storage类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: embeddedMongoConfiguration

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public IMongodConfig embeddedMongoConfiguration() throws IOException {
	IFeatureAwareVersion featureAwareVersion = new ToStringFriendlyFeatureAwareVersion(
			this.embeddedProperties.getVersion(),
			this.embeddedProperties.getFeatures());
	MongodConfigBuilder builder = new MongodConfigBuilder()
			.version(featureAwareVersion);
	if (this.embeddedProperties.getStorage() != null) {
		builder.replication(
				new Storage(this.embeddedProperties.getStorage().getDatabaseDir(),
						this.embeddedProperties.getStorage().getReplSetName(),
						this.embeddedProperties.getStorage().getOplogSize() != null
								? this.embeddedProperties.getStorage().getOplogSize()
								: 0));
	}
	if (getPort() > 0) {
		builder.net(new Net(getHost().getHostAddress(), getPort(),
				Network.localhostIsIPv6()));
	}
	else {
		builder.net(new Net(getHost().getHostAddress(),
				Network.getFreeServerPort(getHost()), Network.localhostIsIPv6()));
	}
	return builder.build();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:27,代码来源:EmbeddedMongoAutoConfiguration.java

示例2: startMangoDb

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
private void startMangoDb() throws InterruptedException {
    startInNewThread(() -> {
        try {
            MongodStarter starter = MongodStarter.getDefaultInstance();
            IMongodConfig mongodConfig = new MongodConfigBuilder()
                    .version(Version.Main.PRODUCTION)
                    .net(new Net(12345, Network.localhostIsIPv6()))
                    .pidFile(new File("target/process.pid").getAbsolutePath())
                    .replication(new Storage(new File("target/tmp/mongodb/").getAbsolutePath(), null, 0))
                    .build();
            logger.debug("Would download MongoDB if not yet downloaded.");
            MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
            logger.debug("Done with downloading MongoDB exec.");
            mongodExecutable.start();

            MongoClientURI uri = new MongoClientURI("mongodb://localhost:12345/eventStreamAnalytics");
            MongoClient client = new MongoClient(uri);
            MongoDatabase mongoDatabase = client.getDatabase(uri.getDatabase());
            mongoDatabase.createCollection("events");
        } catch (Exception ex) {
            logger.error("Failed to start MongoDB", ex);
            throw new RuntimeException(ex);
        }
    }, "MangoDB").join();
    logger.debug("Successfully Started MongoDB.");
}
 
开发者ID:badalgeek,项目名称:EventStreamAnalytics,代码行数:27,代码来源:TestServerManager.java

示例3: crateIMongodConfig

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
private static IMongodConfig crateIMongodConfig(int mongodPort,
    boolean flag, String replicaName) throws UnknownHostException,
    IOException {
  IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder().verbose(false)
      .build();

  Storage replication = new Storage(null, replicaName, 0);
  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .net(new Net(LOCALHOST, mongodPort, Network.localhostIsIPv6()))
      .configServer(flag).replication(replication).cmdOptions(cmdOptions)
      .build();
  return mongodConfig;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:15,代码来源:MongoTestSuit.java

示例4: defaultStorageConfiguration

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
@Test
public void defaultStorageConfiguration() {
	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context, "spring.data.mongodb.port=0");
	this.context.register(EmbeddedMongoAutoConfiguration.class,
			MongoClientConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	Storage replication = this.context.getBean(IMongodConfig.class).replication();
	assertThat(replication.getOplogSize()).isEqualTo(0);
	assertThat(replication.getDatabaseDir()).isNull();
	assertThat(replication.getReplSetName()).isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:EmbeddedMongoAutoConfigurationTests.java

示例5: buildMongodConfiguration

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
private IMongodConfig buildMongodConfiguration(final HostAndPort hostAndPort, final boolean configureReplicaSet) throws IOException {
    final InetAddress address = InetAddress.getByName(hostAndPort.getHost());

    // @formatter:off
    final MongodConfigBuilder builder = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION)
            .net(new Net(hostAndPort.getHost(), hostAndPort.getPort(), address instanceof Inet6Address));
    // @formatter:on

    if (configureReplicaSet) {
        builder.replication(new Storage(null, "test001", 0));
    }
    return builder.build();
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:15,代码来源:MongodManager.java

示例6: crateIMongodConfig

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
private static IMongodConfig crateIMongodConfig(int mongodPort,
    boolean flag, String replicaName) throws UnknownHostException,
    IOException {
  IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder().useNoJournal(false).verbose(false)
      .build();

  Storage replication = new Storage(null, replicaName, 0);
  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .net(new Net(LOCALHOST, mongodPort, Network.localhostIsIPv6()))
      .configServer(flag).replication(replication).cmdOptions(cmdOptions)
      .build();
  return mongodConfig;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:15,代码来源:MongoTestSuit.java

示例7: createReplConfig

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
protected static Map<String, List<IMongodConfig>> createReplConfig(
        final String replSetName,
        final int baseReplSetPort,
        final int numReplicaServers,
        final List<Path> dbDirs
) throws Exception {

    final int opLogSize = 10000;

    final Map<String, List<IMongodConfig>> replMap =
            new HashMap<String, List<IMongodConfig>>(1);

    final List<IMongodConfig> replicas =
            new ArrayList<IMongodConfig>(numReplicaServers);
    for (int i = 0; i < numReplicaServers; i++) {

        final Path dbDir = createTempDirectory().toPath();
        replicas.add(
                new MongodConfigBuilder()
                        .version(Version.Main.PRODUCTION)
                        .net(new Net(baseReplSetPort + i, Network.localhostIsIPv6()))
                        .timeout(new Timeout(50 * 60 * 1000))
                        .replication(
                                new Storage(dbDir.toString(), replSetName, opLogSize))
                        .configServer(false)
                        .pidFile(dbDir.resolve("mongodb.pid").toString())
                        .build());
        dbDirs.add(dbDir);
    }
    replMap.put(replSetName, replicas);
    return replMap;
}
 
开发者ID:CA-APM,项目名称:ca-apm-fieldpack-mongodb,代码行数:33,代码来源:TestUtil.java

示例8: setUp

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
@Override
    public void setUp() {
        offsets = new HashMap<>();
        totalWrittenDocuments = 0;
        try {
            super.setUp();
            mongodStarter = MongodStarter.getDefaultInstance();
            mongodConfig = new MongodConfigBuilder()
                    .version(Version.Main.V3_2)
                    .replication(new Storage(REPLICATION_PATH, "rs0", 1024))
                    .net(new Net(12345, Network.localhostIsIPv6()))
                    .build();
            mongodExecutable = mongodStarter.prepare(mongodConfig);
            mongod = mongodExecutable.start();
            mongoClient = new MongoClient(new ServerAddress("localhost", 12345));
            MongoDatabase adminDatabase = mongoClient.getDatabase("admin");

            BasicDBObject replicaSetSetting = new BasicDBObject();
            replicaSetSetting.put("_id", "rs0");
            BasicDBList members = new BasicDBList();
            DBObject host = new BasicDBObject();
            host.put("_id", 0);
            host.put("host", "127.0.0.1:12345");
            members.add(host);
            replicaSetSetting.put("members", members);
            adminDatabase.runCommand(new BasicDBObject("isMaster", 1));
            adminDatabase.runCommand(new BasicDBObject("replSetInitiate", replicaSetSetting));
            MongoDatabase db = mongoClient.getDatabase("mydb");
            db.createCollection("test1");
            db.createCollection("test2");
            db.createCollection("test3");
        } catch (Exception e) {
//                Assert.assertTrue(false);
        }

        task = new MongodbSourceTask();

        offsetStorageReader = PowerMock.createMock(OffsetStorageReader.class);
        context = PowerMock.createMock(SourceTaskContext.class);
        task.initialize(context);

        sourceProperties = new HashMap<>();
        sourceProperties.put("uri", "mongodb://localhost:12345");
        sourceProperties.put("batch.size", Integer.toString(100));
        sourceProperties.put("schema.name", "schema");
        sourceProperties.put("topic.prefix", "prefix");
        sourceProperties.put("databases", "mydb.test1,mydb.test2,mydb.test3");

    }
 
开发者ID:DataReply,项目名称:kafka-connect-mongodb,代码行数:50,代码来源:MongodbSourceUriTaskTest.java

示例9: setUp

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
@Override
    public void setUp() {
        offsets = new HashMap<>();
        totalWrittenDocuments = 0;
        try {
            super.setUp();
            mongodStarter = MongodStarter.getDefaultInstance();
            mongodConfig = new MongodConfigBuilder()
                    .version(Version.Main.V3_2)
                    .replication(new Storage(REPLICATION_PATH, "rs0", 1024))
                    .net(new Net(12345, Network.localhostIsIPv6()))
                    .build();
            mongodExecutable = mongodStarter.prepare(mongodConfig);
            mongod = mongodExecutable.start();
            mongoClient = new MongoClient(new ServerAddress("localhost", 12345));
            MongoDatabase adminDatabase = mongoClient.getDatabase("admin");

            BasicDBObject replicaSetSetting = new BasicDBObject();
            replicaSetSetting.put("_id", "rs0");
            BasicDBList members = new BasicDBList();
            DBObject host = new BasicDBObject();
            host.put("_id", 0);
            host.put("host", "127.0.0.1:12345");
            members.add(host);
            replicaSetSetting.put("members", members);
            adminDatabase.runCommand(new BasicDBObject("isMaster", 1));
            adminDatabase.runCommand(new BasicDBObject("replSetInitiate", replicaSetSetting));
            MongoDatabase db = mongoClient.getDatabase("mydb");
            db.createCollection("test1");
            db.createCollection("test2");
            db.createCollection("test3");
        } catch (Exception e) {
//                Assert.assertTrue(false);
        }

        task = new MongodbSourceTask();

        offsetStorageReader = PowerMock.createMock(OffsetStorageReader.class);
        context = PowerMock.createMock(SourceTaskContext.class);
        task.initialize(context);

        sourceProperties = new HashMap<>();
        sourceProperties.put("host", "localhost");
        sourceProperties.put("port", Integer.toString(12345));
        sourceProperties.put("batch.size", Integer.toString(100));
        sourceProperties.put("schema.name", "schema");
        sourceProperties.put("topic.prefix", "prefix");
        sourceProperties.put("databases", "mydb.test1,mydb.test2,mydb.test3");

    }
 
开发者ID:DataReply,项目名称:kafka-connect-mongodb,代码行数:51,代码来源:MongodbSourceTaskTest.java

示例10: setup

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  LOG.info("Starting MongoDB embedded instance on {}", port);
  try {
    Files.forceDelete(new File(MONGODB_LOCATION));
  } catch (Exception e) {

  }
  new File(MONGODB_LOCATION).mkdirs();
  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .configServer(false)
      .replication(new Storage(MONGODB_LOCATION, null, 0))
      .net(new Net("localhost", port, Network.localhostIsIPv6()))
      .cmdOptions(new MongoCmdOptionsBuilder()
          .syncDelay(10)
          .useNoPrealloc(true)
          .useSmallFiles(true)
          .useNoJournal(true)
          .build())
      .build();
  mongodExecutable = mongodStarter.prepare(mongodConfig);
  mongodProcess = mongodExecutable.start();

  LOG.info("Insert test data");

  MongoClient client = new MongoClient("localhost", port);
  MongoDatabase database = client.getDatabase(DATABASE);

  MongoCollection collection = database.getCollection(COLLECTION);

  String[] scientists = {"Einstein", "Darwin", "Copernicus", "Pasteur", "Curie", "Faraday",
      "Newton", "Bohr", "Galilei", "Maxwell"};
  for (int i = 1; i <= 1000; i++) {
    int index = i % scientists.length;
    Document document = new Document();
    document.append("_id", i);
    document.append("scientist", scientists[index]);
    collection.insertOne(document);
  }

}
 
开发者ID:apache,项目名称:beam,代码行数:43,代码来源:MongoDbIOTest.java

示例11: mongodConfig

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
private IMongodConfig mongodConfig()
    throws IOException
{
    return new MongodConfigBuilder().version( version() ).net( new Net( mongoPort(), Network.localhostIsIPv6() ) )
        .replication( new Storage( mongoStoragePath().toString(), null, 0 ) ).timeout( new Timeout() ).build();
}
 
开发者ID:cherimojava,项目名称:orchidae,代码行数:7,代码来源:cfgMongo.java

示例12: init

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
@BeforeSuite
public static void init() throws IOException {
    Command command = Command.MongoD;

    try {
        Files.forceDelete(new File(DB_FOLDER_NAME));
    } catch (Exception e) {

    }

    new File(DB_FOLDER_NAME).mkdirs();

    IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION)
            .configServer(false)
            .replication(new Storage(DB_FOLDER_NAME, null, 0))
            .net(new Net(PORT, Network.localhostIsIPv6()))
            .cmdOptions(new MongoCmdOptionsBuilder()
                    .syncDelay(10)
                    .useNoPrealloc(true)
                    .useSmallFiles(true)
                    .useNoJournal(true)
                    .build())
            .build();

    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaults(command)
            .artifactStore(new ArtifactStoreBuilder()
                    .defaults(command)
                    .download(new DownloadConfigBuilder()
                            .defaultsForCommand(command)
                            .downloadPath("https://s3-eu-west-1.amazonaws.com/stratio-mongodb-distribution/")))
            .build();

    MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);

    mongodExecutable = null;

    mongodExecutable = runtime.prepare(mongodConfig);

    mongod = mongodExecutable.start();

}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:44,代码来源:MongoJavaRDDFT.java

示例13: mongodConfig

import de.flapdoodle.embed.mongo.config.Storage; //导入依赖的package包/类
private static IMongodConfig mongodConfig()
    throws IOException
{
    return new MongodConfigBuilder().version( version() ).net( new Net( getPort(), Network.localhostIsIPv6() ) )
        .replication( new Storage( storagePath, null, 0 ) ).timeout( new Timeout() ).build();
}
 
开发者ID:cherimojava,项目名称:cherimodata,代码行数:7,代码来源:Suite.java


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