本文整理汇总了Java中com.github.tlrx.elasticsearch.test.EsSetup类的典型用法代码示例。如果您正苦于以下问题:Java EsSetup类的具体用法?Java EsSetup怎么用?Java EsSetup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EsSetup类属于com.github.tlrx.elasticsearch.test包,在下文中一共展示了EsSetup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClass
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
final Settings settings = ImmutableSettings.settingsBuilder().put("script.disable_dynamic", false)
.put("script.native.visibility.type", "ezbake.data.elastic.security.EzSecurityScriptFactory").build();
esSetup = new EsSetup(settings);
esSetup.execute(EsSetup.deleteAll());
createIndexAndType();
writeTestDoc("noVis", null, null, null, null, "noVisData");
writeTestDoc("formalVisOnly", "TS&USA", null, null, null, "formalVisOnlyData");
writeTestDoc("formalAndExternalVis", "TS&USA", "Foo&(Bar|Baz)", null, null, "formalAndExternalVisData");
writeTestDoc(
"allVis", "TS&USA", "Foo&(Bar|Baz)", Sets.newHashSet(92472393432L),
Sets.newHashSet(324L, 43267L, 92472393432L), "allVisData");
Thread.sleep(2000); // Wait for docs to be added
}
示例2: setUpHttp
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setUpHttp() throws Exception {
Configuration.getInstance().setProperty(CoreConfig.DISCOVERY_MODULES.name(),
"com.rackspacecloud.blueflood.io.ElasticIO");
Configuration.getInstance().setProperty(CoreConfig.USE_ES_FOR_UNITS.name(), "true");
queryPort = Configuration.getInstance().getIntegerProperty(HttpConfig.HTTP_METRIC_DATA_QUERY_PORT);
httpQueryService = new HttpQueryService();
httpQueryService.startService();
vendor = new HttpClientVendor();
client = vendor.getClient();
esSetup = new EsSetup();
esSetup.execute(EsSetup.deleteAll());
esSetup.execute(EsSetup.createIndex(ElasticIO.ELASTICSEARCH_INDEX_NAME_WRITE)
.withSettings(EsSetup.fromClassPath("index_settings.json"))
.withMapping("metrics", EsSetup.fromClassPath("metrics_mapping.json")));
elasticIO = new ElasticIO(esSetup.client());
}
示例3: setupElasticSearch
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
private static void setupElasticSearch() {
// setup elasticsearch
// setup config
System.setProperty(CoreConfig.DISCOVERY_MODULES.name(), "com.rackspacecloud.blueflood.io.ElasticIO");
System.setProperty(CoreConfig.EVENTS_MODULES.name(), "com.rackspacecloud.blueflood.io.EventElasticSearchIO");
// setup elasticsearch test clusters with blueflood mappings
esSetup = new EsSetup();
esSetup.execute(EsSetup.deleteAll());
esSetup.execute(EsSetup.createIndex(ElasticIO.ELASTICSEARCH_INDEX_NAME_WRITE)
.withSettings(EsSetup.fromClassPath("index_settings.json"))
.withMapping("metrics", EsSetup.fromClassPath("metrics_mapping.json")));
esSetup.execute(EsSetup.createIndex(EventElasticSearchIO.EVENT_INDEX)
.withSettings(EsSetup.fromClassPath("index_settings.json"))
.withMapping("graphite_event", EsSetup.fromClassPath("events_mapping.json")));
// create elaticsearch client and link it to ModuleLoader
elasticIO = new ElasticIO(esSetup.client());
eventsSearchIO = new EventElasticSearchIO(esSetup.client());
((ElasticIO) ModuleLoader.getInstance(DiscoveryIO.class, CoreConfig.DISCOVERY_MODULES)).setClient(esSetup.client());
}
示例4: setUp
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception{
System.setProperty(CoreConfig.EVENTS_MODULES.name(), "com.rackspacecloud.blueflood.io.EventElasticSearchIO");
Configuration.getInstance().init();
httpPort = Configuration.getInstance().getIntegerProperty(HttpConfig.HTTP_INGESTION_PORT);
manageShards.add(1); manageShards.add(5); manageShards.add(6);
context = spy(new ScheduleContext(System.currentTimeMillis(), manageShards));
esSetup = new EsSetup();
esSetup.execute(EsSetup.deleteAll());
esSetup.execute(EsSetup.createIndex(EventElasticSearchIO.EVENT_INDEX)
.withSettings(EsSetup.fromClassPath("index_settings.json"))
.withMapping("graphite_event", EsSetup.fromClassPath("events_mapping.json")));
eventsSearchIO = new EventElasticSearchIO(esSetup.client());
server = new HttpMetricsIngestionServer(context);
server.setHttpEventsIngestionHandler(new HttpEventsIngestionHandler(eventsSearchIO));
server.startServer();
vendor = new HttpClientVendor();
client = vendor.getClient();
}
示例5: setup
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@Before
public void setup() throws Exception {
esSetup = new EsSetup();
esSetup.execute(EsSetup.deleteAll());
esSetup.execute(EsSetup
.createIndex(EventElasticSearchIO.EVENT_INDEX)
.withMapping(EventElasticSearchIO.ES_TYPE, EsSetup.fromClassPath("events_mapping.json")));
searchIO = new EventElasticSearchIO(esSetup.client());
createTestEvents(TENANT_1, TENANT_1_EVENTS_NUM);
createTestEvents(TENANT_2, TENANT_2_EVENTS_NUM);
createTestEvents(TENANT_WITH_SYMBOLS, TENANT_WITH_SYMBOLS_NUM);
createRangeEvents(TENANT_RANGE, TENANT_RANGE_EVENTS_NUM, RANGE_STEP_IN_SECONDS);
esSetup.client().admin().indices().prepareRefresh().execute().actionGet();
}
示例6: testWithMultipleNodes
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
/**
* Export request must also work with multiple nodes.
*/
@Test
public void testWithMultipleNodes() {
// Prepare a second node and wait for relocation
esSetup2 = new EsSetup();
esSetup2.execute(index("users", "d").withSource("{\"name\": \"motorbike\"}"));
esSetup2.client().admin().cluster().prepareHealth().setWaitForGreenStatus().
setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet();
// Do export request
String source = "{\"output_cmd\": \"cat\", \"fields\": [\"name\"]}";
ExportRequest exportRequest = new ExportRequest();
exportRequest.source(source);
ExportResponse response = esSetup2.client().execute(
ExportAction.INSTANCE, exportRequest).actionGet();
// The two shard results are from different nodes and have no failures
assertEquals(0, response.getFailedShards());
List<Map<String, Object>> infos = getExports(response);
assertNotSame(infos.get(0).get("node_id"), infos.get(1).get("node_id"));
}
示例7: testExportRelativeFilename
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
/**
* If the path of the output file is relative, the files are put to the data directory
* of each node in a sub directory /export .
*/
@Test
public void testExportRelativeFilename() {
esSetup2 = new EsSetup();
esSetup2.execute(index("users", "d").withSource("{\"name\": \"motorbike\"}"));
esSetup2.client().admin().cluster().prepareHealth().setWaitForGreenStatus().
setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet();
ExportResponse response = executeExportRequest(
"{\"output_file\": \"export.${shard}.${index}.json\", \"fields\": [\"name\", \"_id\"], \"force_overwrite\": true}");
List<Map<String, Object>> infos = getExports(response);
assertEquals(2, infos.size());
String output_file_0 = infos.get(0).get("output_file").toString();
String output_file_1 = infos.get(1).get("output_file").toString();
Pattern p = Pattern.compile("(.*)/nodes/(\\d)/export.(\\d).users.json");
Matcher m0 = p.matcher(output_file_0);
Matcher m1 = p.matcher(output_file_1);
assertTrue(m0.find());
assertTrue(m1.find());
assertTrue(m0.group(2) != m1.group(2));
}
示例8: setESandMongodb
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setESandMongodb() throws IOException {
// Instantiates a local node & client
esSetup = new EsSetup();
// Clean all, and creates some indices
esSetup.execute(
deleteAll(),
createIndex("my_index_1")
//.withMapping("annotation", fromClassPath("/home/azhar/NetBeansProjects/anHALytics-core/anhalytics-index/src/main/resources/elasticSearch/annotation.json"))
,
createIndex("my_index_2")
//.withMapping("npl", fromClassPath("/home/azhar/NetBeansProjects/anHALytics-core/anhalytics-index/src/main/resources/elasticSearch/npl.json"))
//.withData(fromClassPath("path/to/bulk.json"))
);
_mongodExe = starter.prepare(new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(12345, Network.localhostIsIPv6()))
.build());
_mongod = _mongodExe.start();
MongoClient _mongo = new MongoClient("localhost", 12345);
db = _mongo.getDB(DATABASE_NAME);
(mm = new MongoManager(true)).setDB(db);
System.out.println("ElasticSearch and Mongodb are ready to use...");
}
示例9: setUp
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@Before
public void setUp() {
esSetup = new EsSetup(settings);
esSetup.execute(createIndex(index));
drpc = new LocalDRPC();
StormTopology topology = buildTopology();
cluster = new LocalCluster();
cluster.submitTopology("elastic-storm", new Config(), topology);
Utils.sleep(10000); // let's do some work
}
示例10: setupClass
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setupClass() throws Exception {
final Settings settings = ImmutableSettings.settingsBuilder().put("script.disable_dynamic", false)
.put("script.native.visibility.type", "ezbake.data.elastic.security.EzSecurityScriptFactory").build();
esSetup = new EsSetup(settings);
esSetup.execute(EsSetup.deleteAll());
if (esSetup.client() == null) {
throw new Exception("Could not start EsSetup node!");
}
}
示例11: setUpClass
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
gson = new GsonBuilder().setDateFormat("ddHHmm'Z' MMM yy").create();
configuration = new EzConfiguration(new ClasspathConfigurationLoader()).getProperties();
final EzBakeApplicationConfigurationHelper appConfig = new EzBakeApplicationConfigurationHelper(configuration);
final String securityId = appConfig.getSecurityID();
fakeSecurity =
ThriftTestUtils.generateTestSecurityToken(securityId, securityId, Collections.singletonList("U"));
applicationName = appConfig.getApplicationName();
configuration.setProperty(EzBakePropertyConstants.ELASTICSEARCH_CLUSTER_NAME, "elasticsearch");
final ElasticsearchConfigurationHelper helper = new ElasticsearchConfigurationHelper(configuration);
final Settings settings = ImmutableSettings.settingsBuilder()
.put("script.native.visibility.type", "ezbake.data.elastic.security.EzSecurityScriptFactory")
.put("cluster.name", helper.getElasticsearchClusterName()).put("script.disable_dynamic", false)
.put("network.host", helper.getElasticsearchHost())
.put("transport.tcp.port", helper.getElasticsearchPort()).put("node.local", false).build();
esSetup = new EsSetup(settings);
esSetup.execute(EsSetup.deleteAll());
if (esSetup.client() == null) {
throw new Exception("Could not start EsSetup node!");
}
}
示例12: setUp
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
System.setProperty(CoreConfig.EVENTS_MODULES.name(), "com.rackspacecloud.blueflood.io.EventElasticSearchIO");
Configuration.getInstance().init();
httpPort = Configuration.getInstance().getIntegerProperty(HttpConfig.HTTP_INGESTION_PORT);
queryPort = Configuration.getInstance().getIntegerProperty(HttpConfig.HTTP_METRIC_DATA_QUERY_PORT);
manageShards.add(1); manageShards.add(5); manageShards.add(6);
context = spy(new ScheduleContext(System.currentTimeMillis(), manageShards));
esSetup = new EsSetup();
esSetup.execute(EsSetup.deleteAll());
esSetup.execute(EsSetup.createIndex(EventElasticSearchIO.EVENT_INDEX)
.withSettings(EsSetup.fromClassPath("index_settings.json"))
.withMapping("graphite_event", EsSetup.fromClassPath("events_mapping.json")));
eventsSearchIO = new EventElasticSearchIO(esSetup.client());
HttpMetricsIngestionServer server = new HttpMetricsIngestionServer(context);
server.setHttpEventsIngestionHandler(new HttpEventsIngestionHandler(eventsSearchIO));
httpIngestionService = new HttpIngestionService();
httpIngestionService.setMetricsIngestionServer(server);
httpIngestionService.startService(context);
httpQueryService = new HttpQueryService();
HttpMetricDataQueryServer queryServer = new HttpMetricDataQueryServer();
queryServer.setEventsIO(eventsSearchIO);
httpQueryService.setServer(queryServer);
httpQueryService.startService();
vendor = new HttpClientVendor();
client = vendor.getClient();
}
示例13: testDeDupMetrics
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@Test
public void testDeDupMetrics() throws Exception {
// New index name and the locator to be written to it
String ES_DUP = ElasticIO.ELASTICSEARCH_INDEX_NAME_WRITE + "_2";
Locator testLocator = createTestLocator(TENANT_A, 0, "A", 0);
// Metric is aleady there in old
List<SearchResult> results = elasticIO.search(TENANT_A, testLocator.getMetricName());
assertEquals(results.size(), 1);
assertEquals(results.get(0).getMetricName(), testLocator.getMetricName());
// Actually create the new index
esSetup.execute(EsSetup.createIndex(ES_DUP)
.withSettings(EsSetup.fromClassPath("index_settings.json"))
.withMapping("metrics", EsSetup.fromClassPath("metrics_mapping.json")));
// Insert metric into the new index
elasticIO.setINDEX_NAME_WRITE(ES_DUP);
ArrayList metricList = new ArrayList();
metricList.add(new Metric(createTestLocator(TENANT_A, 0, "A", 0), 987654321L, 0, new TimeValue(1, TimeUnit.DAYS), UNIT));
elasticIO.insertDiscovery(metricList);
esSetup.client().admin().indices().prepareRefresh().execute().actionGet();
// Set up aliases
esSetup.client().admin().indices().prepareAliases().addAlias(ES_DUP, "metric_metadata_read")
.addAlias(ElasticIO.ELASTICSEARCH_INDEX_NAME_WRITE, "metric_metadata_read").execute().actionGet();
elasticIO.setINDEX_NAME_READ("metric_metadata_read");
results = elasticIO.search(TENANT_A, testLocator.getMetricName());
// Should just be one result
assertEquals(results.size(), 1);
assertEquals(results.get(0).getMetricName(), testLocator.getMetricName());
elasticIO.setINDEX_NAME_READ(ElasticIOConfig.ELASTICSEARCH_INDEX_NAME_READ.getDefaultValue());
elasticIO.setINDEX_NAME_WRITE(ElasticIOConfig.ELASTICSEARCH_INDEX_NAME_WRITE.getDefaultValue());
}
示例14: testWithMultipleNodes
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
/**
* Dump request must also work with multiple nodes.
*/
@Test
public void testWithMultipleNodes() {
// make sure target directory exists and is empty
File dumpDir = new File("/tmp/multipleNodes");
if (dumpDir.exists()) {
for (File c : dumpDir.listFiles()) {
c.delete();
}
dumpDir.delete();
}
dumpDir.mkdir();
// Prepare a second node and wait for relocation
esSetup2 = new EsSetup();
esSetup2.execute(index("users", "d").withSource("{\"name\": \"motorbike\"}"));
esSetup2.client().admin().cluster().prepareHealth().setWaitForGreenStatus().
setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet();
// Do dump request
String source = "{\"force_overwrite\": true, \"directory\":\"/tmp/multipleNodes\"}";
ExportRequest exportRequest = new ExportRequest();
exportRequest.source(source);
ExportResponse response = esSetup.client().execute(
DumpAction.INSTANCE, exportRequest).actionGet();
// The two shard results are from different nodes and have no failures
assertEquals(0, response.getFailedShards());
List<Map<String, Object>> infos = getExports(response);
assertNotSame(infos.get(0).get("node_id"), infos.get(1).get("node_id"));
}
示例15: setUp
import com.github.tlrx.elasticsearch.test.EsSetup; //导入依赖的package包/类
@Before
public void setUp() {
esSetup = new EsSetup();
esSetup.execute(deleteAll(), createIndex("users").withSettings(
fromClassPath("essetup/settings/test_a.json")).withMapping("d",
fromClassPath("essetup/mappings/test_a.json")).withData(
fromClassPath("essetup/data/test_a.json")));
esSetup.client().admin().indices().prepareRefresh("users").execute();
}