本文整理汇总了Java中org.elasticsearch.cluster.metadata.IndexMetaData.getSettings方法的典型用法代码示例。如果您正苦于以下问题:Java IndexMetaData.getSettings方法的具体用法?Java IndexMetaData.getSettings怎么用?Java IndexMetaData.getSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.cluster.metadata.IndexMetaData
的用法示例。
在下文中一共展示了IndexMetaData.getSettings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateIndexMetaData
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
/**
* Updates the settings and index metadata and notifies all registered settings consumers with the new settings iff at least one setting has changed.
*
* @return <code>true</code> iff any setting has been updated otherwise <code>false</code>.
*/
public synchronized boolean updateIndexMetaData(IndexMetaData indexMetaData) {
final Settings newSettings = indexMetaData.getSettings();
if (version.equals(Version.indexCreated(newSettings)) == false) {
throw new IllegalArgumentException("version mismatch on settings update expected: " + version + " but was: " + Version.indexCreated(newSettings));
}
final String newUUID = newSettings.get(IndexMetaData.SETTING_INDEX_UUID, IndexMetaData.INDEX_UUID_NA_VALUE);
if (newUUID.equals(getUUID()) == false) {
throw new IllegalArgumentException("uuid mismatch on settings update expected: " + getUUID() + " but was: " + newUUID);
}
this.indexMetaData = indexMetaData;
final Settings existingSettings = this.settings;
if (existingSettings.filter(IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE).getAsMap().equals(newSettings.filter(IndexScopedSettings.INDEX_SETTINGS_KEY_PREDICATE).getAsMap())) {
// nothing to update, same settings
return false;
}
scopedSettings.applySettings(newSettings);
this.settings = Settings.builder().put(nodeSettings).put(newSettings).build();
return true;
}
示例2: tableParametersFromIndexMetaData
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
public static ImmutableMap<String,Object> tableParametersFromIndexMetaData(IndexMetaData metaData) {
Settings settings = metaData.getSettings();
return ImmutableMap.<String,Object>builder()
.put(TableParameterInfo.READ_ONLY, CrateTableSettings.READ_ONLY.extract(settings))
.put(TableParameterInfo.BLOCKS_READ, CrateTableSettings.BLOCKS_READ.extract(settings))
.put(TableParameterInfo.BLOCKS_WRITE, CrateTableSettings.BLOCKS_WRITE.extract(settings))
.put(TableParameterInfo.BLOCKS_METADATA, CrateTableSettings.BLOCKS_METADATA.extract(settings))
.put(TableParameterInfo.FLUSH_THRESHOLD_OPS, CrateTableSettings.FLUSH_THRESHOLD_OPS.extract(settings))
.put(TableParameterInfo.FLUSH_THRESHOLD_PERIOD, CrateTableSettings.FLUSH_THRESHOLD_PERIOD.extractMillis(settings))
.put(TableParameterInfo.FLUSH_THRESHOLD_SIZE, CrateTableSettings.FLUSH_THRESHOLD_SIZE.extractBytes(settings))
.put(TableParameterInfo.FLUSH_DISABLE, CrateTableSettings.FLUSH_DISABLE.extract(settings))
.put(TableParameterInfo.TRANSLOG_INTERVAL, CrateTableSettings.TRANSLOG_INTERVAL.extractMillis(settings))
.put(TableParameterInfo.ROUTING_ALLOCATION_ENABLE, CrateTableSettings.ROUTING_ALLOCATION_ENABLE.extract(settings))
.put(TableParameterInfo.TOTAL_SHARDS_PER_NODE, CrateTableSettings.TOTAL_SHARDS_PER_NODE.extract(settings))
.put(TableParameterInfo.RECOVERY_INITIAL_SHARDS, CrateTableSettings.RECOVERY_INITIAL_SHARDS.extract(settings))
.put(TableParameterInfo.WARMER_ENABLED, CrateTableSettings.WARMER_ENABLED.extract(settings))
.put(TableParameterInfo.TRANSLOG_SYNC_INTERVAL, CrateTableSettings.TRANSLOG_SYNC_INTERVAL.extractMillis(settings))
.put(TableParameterInfo.REFRESH_INTERVAL, CrateTableSettings.REFRESH_INTERVAL.extractMillis(settings))
.put(TableParameterInfo.UNASSIGNED_NODE_LEFT_DELAYED_TIMEOUT, CrateTableSettings.UNASSIGNED_NODE_LEFT_DELAYED_TIMEOUT.extractMillis(settings))
.put(TableParameterInfo.USING_DL_ENGINE, CrateTableSettings.USING_DL_ENGINE.extract(settings))
.put(TableParameterInfo.DL_SNAPSHOT_RECOVERY_ROWS, CrateTableSettings.DL_SNAPSHOT_RECOVERY_ROWS.extract(settings))
.build();
}
示例3: DocIndexMetaData
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
public DocIndexMetaData(Functions functions, IndexMetaData metaData, TableIdent ident) throws IOException {
this.functions = functions;
this.ident = ident;
this.metaData = metaData;
this.isAlias = !metaData.getIndex().equals(ident.indexName());
this.numberOfShards = metaData.getNumberOfShards();
Settings settings = metaData.getSettings();
this.numberOfReplicas = NumberOfReplicas.fromSettings(settings);
this.aliases = ImmutableSet.copyOf(metaData.getAliases().keys().toArray(String.class));
this.defaultMappingMetaData = this.metaData.mappingOrDefault(Constants.DEFAULT_MAPPING_TYPE);
if (defaultMappingMetaData == null) {
this.defaultMappingMap = ImmutableMap.of();
} else {
this.defaultMappingMap = this.defaultMappingMetaData.sourceAsMap();
}
this.tableParameters = TableParameterInfo.tableParametersFromIndexMetaData(metaData);
Map<String, Object> metaMap = getNested(defaultMappingMap, "_meta");
indicesMap = getNested(metaMap, "indices", ImmutableMap.<String, Object>of());
partitionedByList = getNested(metaMap, "partitioned_by", ImmutableList.<List<String>>of());
generatedColumns = getNested(metaMap, "generated_columns", ImmutableMap.<String, String>of());
}
示例4: buildShardLevelInfo
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
static void buildShardLevelInfo(ESLogger logger, ShardStats[] stats, HashMap<String, Long> newShardSizes, HashMap<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
MetaData meta = state.getMetaData();
for (ShardStats s : stats) {
IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
Settings indexSettings = indexMeta == null ? null : indexMeta.getSettings();
newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
long size = s.getStats().getStore().sizeInBytes();
String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
if (logger.isTraceEnabled()) {
logger.trace("shard: {} size: {}", sid, size);
}
if (indexSettings != null && IndexMetaData.isIndexUsingShadowReplicas(indexSettings)) {
// Shards on a shared filesystem should be considered of size 0
if (logger.isTraceEnabled()) {
logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
}
size = 0;
}
newShardSizes.put(sid, size);
}
}
示例5: getAllocationComparator
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
/**
* Returns a PriorityComparator that uses the RoutingAllocation index metadata to access the index setting per index.
*/
public static PriorityComparator getAllocationComparator(final RoutingAllocation allocation) {
return new PriorityComparator() {
@Override
protected Settings getIndexSettings(Index index) {
IndexMetaData indexMetaData = allocation.metaData().getIndexSafe(index);
return indexMetaData.getSettings();
}
};
}
示例6: CopyIndexMetadata
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
public void CopyIndexMetadata(Client sourceclient, String sourceindex, Client targetclient, String targetindex)
throws UnknownHostException {
// TODO Auto-generated method stub
// 获取source settings
Settings.Builder settingbuilder = Settings.builder();
ClusterState cs = sourceclient.admin().cluster().prepareState().setIndices(sourceindex).execute().actionGet()
.getState();
IndexMetaData imd = cs.getMetaData().index(sourceindex);
Settings settings = imd.getSettings();
for (Map.Entry<String, String> m : settings.getAsMap().entrySet()) {
if (m.getKey().equals("index.uuid") || m.getKey().equals("index.version.created")
|| m.getKey().equals("index.creation_date")) {
continue;
} else {
settingbuilder.put(m.getKey(), m.getValue());
}
}
// 创建索引
targetclient.admin().indices().prepareCreate(targetindex).setSettings(settingbuilder).get();
// 获取source mappings并添加到target
try {
GetMappingsResponse res = sourceclient.admin().indices()
.getMappings(new GetMappingsRequest().indices(sourceindex)).get();
ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(sourceindex);
for (ObjectObjectCursor<String, MappingMetaData> c : mapping) {
targetclient.admin().indices().preparePutMapping(targetindex).setType(c.key)
.setSource(c.value.getSourceAsMap()).get();
}
} catch (InterruptedException | ExecutionException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.info("Target index " + targetindex + " create complete!");
}
示例7: getAllocationComparator
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
/**
* Returns a PriorityComparator that uses the RoutingAllocation index metadata to access the index setting per index.
*/
public static PriorityComparator getAllocationComparator(final RoutingAllocation allocation) {
return new PriorityComparator() {
@Override
protected Settings getIndexSettings(String index) {
IndexMetaData indexMetaData = allocation.metaData().index(index);
return indexMetaData.getSettings();
}
};
}
示例8: IndexScopedSettings
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
private IndexScopedSettings(Settings settings, IndexScopedSettings other, IndexMetaData metaData) {
super(settings, metaData.getSettings(), other);
}
示例9: backupIdxMeta
import org.elasticsearch.cluster.metadata.IndexMetaData; //导入方法依赖的package包/类
/**
* 备份索引settings
*
* @param client
* @param indexname
* @param file
* @throws FileNotFoundException
* @throws IOException
* @throws ExecutionException
* @throws InterruptedException
*/
public void backupIdxMeta() throws FileNotFoundException, IOException, InterruptedException, ExecutionException {
logmsg = new HashMap<String, Object>();
// 获取index settings
ClusterState cs = backup.getClient().admin().cluster().prepareState().setIndices(backup.getIndexname())
.execute().actionGet().getState();
IndexMetaData imd = cs.getMetaData().index(backup.getIndexname());
IndexMeta indexmeta = new IndexMeta();
Settings settings = imd.getSettings();
Map<String, String> set = settings.getAsMap();
indexmeta.setIdxsetting(set);
// 获取index mapping
Map<String, Object> mapping = new HashMap<String, Object>();
GetMappingsResponse res = backup.getClient().admin().indices()
.getMappings(new GetMappingsRequest().indices(backup.getIndexname())).get();
ImmutableOpenMap<String, MappingMetaData> idxmapping = res.mappings().get(backup.getIndexname());
for (ObjectObjectCursor<String, MappingMetaData> c : idxmapping) {
mapping.put(c.key, c.value.getSourceAsMap());
}
indexmeta.setIdxmapping(mapping);
// 序列化对象到文件
if (!backup.getBackuppath().endsWith(File.separator)) {
backup.setBackuppath(backup.getBackuppath() + File.separator);
}
if (0 == backup.getBackuppath().indexOf("./")) {
backup.setBackuppath(backup.getBackuppath().replace("./", ""));
}
// IndexMetaData 转 json
ObjectMapper mapper = new ObjectMapper();
String indexmetajson = mapper.writeValueAsString(indexmeta);
// 写入文件
String filename = backup.getBackuppath() + backup.getIndexname() + ".meta";
FileWriter fw = new FileWriter(filename);
fw.write(indexmetajson);
fw.flush();
fw.close();
// 写日志
logmsg.put("Action", "backup index meta");
logmsg.put("Index", backup.getIndexname());
logmsg.put("backupfile", new File(backup.getBackuppath() + backup.getIndexname() + ".meta").getAbsolutePath());
logger.info(jsonutil.MapToJson(logmsg));
}