本文整理汇总了Java中org.elasticsearch.common.collect.ImmutableMap类的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMap类的具体用法?Java ImmutableMap怎么用?Java ImmutableMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImmutableMap类属于org.elasticsearch.common.collect包,在下文中一共展示了ImmutableMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listBlobsByPrefix
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
@Override
public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException {
ImmutableMap.Builder<String, BlobMetaData> blobsBuilder = ImmutableMap.builder();
List<GridFSDBFile> files;
if (blobNamePrefix != null) {
files = blobStore.gridFS().find(new BasicDBObject("filename", "/^" + buildKey(blobNamePrefix) + "/"));
} else {
files = blobStore.gridFS().find(new BasicDBObject("filename", "/^" + keyPath + "/"));
}
if (files != null && !files.isEmpty()) {
for (GridFSDBFile file : files) {
String name = file.getFilename().substring(keyPath.length());
blobsBuilder.put(name, new PlainBlobMetaData(name, file.getLength()));
}
}
return blobsBuilder.build();
}
示例2: listBlobs
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
@Override
public ImmutableMap<String, BlobMetaData> listBlobs(URL url) throws IOException {
HttpURLConnection con = (HttpURLConnection) url.openConnection();
try {
if (basicAuth != null) {
con.setRequestProperty("Authorization", basicAuth);
}
setPropFindMethod(con);
int statusCode = con.getResponseCode();
String responseMessage = con.getResponseMessage();
if (statusCode >= SC_OK && statusCode < SC_MULTIPLE_CHOICES) {
return PropFindResponseParser.parse(con.getInputStream());
}
if (statusCode == SC_NOT_FOUND) {
return emptyMap;
}
throw new IOException("status code: " + statusCode + " message: " + responseMessage);
} finally {
con.disconnect();
}
}
示例3: listBlobs
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
@Override
public ImmutableMap<String, BlobMetaData> listBlobs(URL url) throws IOException {
ImmutableMap.Builder<String, BlobMetaData> builder = ImmutableMap.builder();
DavEntry davEntry = getEntry(url);
if (davEntry == null) {
return builder.build();
}
for (Map.Entry<String, DavEntry> resourceEntry : davEntry.children.entrySet()) {
BlobMetaData blobMetaData = new MockBlobMetaData(
resourceEntry.getKey(),
resourceEntry.getValue().outputStream != null
? resourceEntry.getValue().outputStream.size()
: 0);
builder.put(resourceEntry.getKey(), blobMetaData);
}
return builder.build();
}
示例4: isBenchmarkNode
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
private final boolean isBenchmarkNode(DiscoveryNode node) {
ImmutableMap<String, String> attributes = node.getAttributes();
if (attributes.containsKey("bench")) {
String bench = attributes.get("bench");
return Boolean.parseBoolean(bench);
}
return false;
}
示例5: createIndex
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
/**
* Create the index
*/
public static void createIndex(String indexName) {
Logger.debug("ElasticSearch : creating index [" + indexName + "]");
final String jsonNode = IndexClient.config.indexSettings.get(indexName);
final CreateIndex.Builder builder = new CreateIndex.Builder(indexName);
if (StringUtils.isNotBlank(jsonNode)) {
final ImmutableMap<String, String> settings = ImmutableSettings.builder().loadFromSource(jsonNode).build().getAsMap();
builder.settings(settings);
}
final JestRichResult jestResult = execute(builder.build());
log(jestResult, "index creation result =>");
}
示例6: rivers
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
/**
* Retrieve the registered rivers using reflection. This hack can be removed when RiversService gets a public API.
*
* @param injector injector
* @return map of rivers or null if not possible
*/
@SuppressWarnings({"unchecked"})
public static ImmutableMap<RiverName, River> rivers(Injector injector) {
RiversService riversService = injector.getInstance(RiversService.class);
try {
Field field = RiversService.class.getDeclaredField("rivers");
if (field != null) {
field.setAccessible(true);
return (ImmutableMap<RiverName, River>) field.get(riversService);
}
} catch (Throwable e) {
//
}
return ImmutableMap.of();
}
示例7: clusterChanged
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
@Override
public void clusterChanged(ClusterChangedEvent event) {
RiverStatesMetaData oldMetadata = event.previousState().getMetaData().custom(RiverStatesMetaData.TYPE);
RiverStatesMetaData newMetadata = event.state().getMetaData().custom(RiverStatesMetaData.TYPE);
if ((oldMetadata == null && newMetadata == null) || (oldMetadata != null && oldMetadata.equals(newMetadata))) {
return;
}
Map<String, RiverState> survivors = newHashMap();
for (Map.Entry<String, RiverState> entry : riverStates.entrySet()) {
if (newMetadata != null && newMetadata.river(entry.getKey()) != null) {
survivors.put(entry.getKey(), entry.getValue());
}
}
ImmutableMap.Builder<String, RiverState> builder = ImmutableMap.builder();
if (newMetadata != null) {
for (RiverState riverMetaData : newMetadata.rivers()) {
RiverState riverState = survivors.get(riverMetaData.getName());
if (riverState != null) {
if (!riverState.getType().equals(riverMetaData.getType()) || !riverState.getSettings().equals(riverMetaData.getSettings())) {
logger.debug("updating river state [{}]", riverMetaData.getName());
riverState = riverMetaData;
}
} else {
riverState = riverMetaData;
}
logger.debug("registering river state [{}]", riverMetaData.getName());
builder.put(riverMetaData.getName(), riverState);
}
}
}
示例8: registerRiver
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
private boolean registerRiver(RiverState riverMetaData) {
RiverState previous = riverStates.get(riverMetaData.getName());
if (previous != null) {
if (!previous.getType().equals(riverMetaData.getType()) && previous.getSettings().equals(riverMetaData.getSettings())) {
return false;
}
}
Map<String, RiverState> newRiverStates = newHashMap();
newRiverStates.put(riverMetaData.getName(), riverMetaData);
riverStates = ImmutableMap.copyOf(newRiverStates);
return true;
}
示例9: testNormal
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
public void testNormal() {
Settings globalSettings = ImmutableSettings.settingsBuilder().put("cluster.name", "jason-hfs-cluster").build();
Map<String, Object> config = new HashMap<>();
config.put("statsd", ImmutableMap.<String, Object> builder().put("host", "localhost").put("port", "1234").put("prefix", "my_prefix").build());
StatsReporter r = new StatsReporter(new KafkaRiverConfig(new RiverSettings(globalSettings, config)));
assertTrue(r.isEnabled());
}
示例10: testNotConfigured
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
public void testNotConfigured() {
Settings globalSettings = ImmutableSettings.settingsBuilder().put("cluster.name", "jason-hfs-cluster").build();
Map<String, Object> config = new HashMap<>();
// no statsd config at all
assertFalse(new StatsReporter(new KafkaRiverConfig(new RiverSettings(globalSettings, config))).isEnabled());
// missing host
config.put("statsd", ImmutableMap.<String, Object> builder().put("port", "1234").put("prefix", "my_prefix").build());
assertFalse(new StatsReporter(new KafkaRiverConfig(new RiverSettings(globalSettings, config))).isEnabled());
}
示例11: getMissingIndexes
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
private Set<String> getMissingIndexes(Set<String> indexes) {
try {
ImmutableMap<String, IndexMetaData> foundIndices = getIndexMetaData(indexes);
indexes.removeAll(foundIndices.keySet());
} catch (IndexMissingException e) {
// all indexes are missing
}
return indexes;
}
示例12: getIndexMetaData
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
private ImmutableMap<String, IndexMetaData> getIndexMetaData(Set<String> indexes) {
ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
.filterRoutingTable(true)
.filterNodes(true)
.filteredIndices(indexes.toArray(new String[indexes.size()]));
clusterStateRequest.listenerThreaded(false);
ClusterStateResponse response = client.admin().cluster().state(clusterStateRequest).actionGet();
return ImmutableMap.copyOf(response.getState().metaData().indices());
}
示例13: DumpParser
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
@Inject
public DumpParser(QueryPhase queryPhase, FetchPhase fetchPhase) {
Map<String, SearchParseElement> elementParsers = new HashMap<String, SearchParseElement>();
elementParsers.putAll(queryPhase.parseElements());
elementParsers.put("force_overwrite", new ExportForceOverwriteParseElement());
elementParsers.put("directory", directoryParseElement);
this.elementParsers = ImmutableMap.copyOf(elementParsers);
}
示例14: ImportParser
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
public ImportParser() {
Map<String, ImportParseElement> elementParsers = new HashMap<String, ImportParseElement>();
elementParsers.put("directory", new DirectoryParseElement());
elementParsers.put("compression", new ImportCompressionParseElement());
elementParsers.put("file_pattern", new FilePatternParseElement());
elementParsers.put("mappings", new ImportMappingsParseElement());
elementParsers.put("settings", new ImportSettingsParseElement());
this.elementParsers = ImmutableMap.copyOf(elementParsers);
}
示例15: ReindexParser
import org.elasticsearch.common.collect.ImmutableMap; //导入依赖的package包/类
@Inject
public ReindexParser(QueryPhase queryPhase, FetchPhase fetchPhase) {
Map<String, SearchParseElement> elementParsers = new HashMap<String,
SearchParseElement>();
elementParsers.putAll(queryPhase.parseElements());
elementParsers.put("explain", new ExplainParseElement());
this.elementParsers = ImmutableMap.copyOf(elementParsers);
}