本文整理汇总了Java中org.elasticsearch.common.settings.Settings.getAsMap方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.getAsMap方法的具体用法?Java Settings.getAsMap怎么用?Java Settings.getAsMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.settings.Settings
的用法示例。
在下文中一共展示了Settings.getAsMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertSettings
import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
public static void assertSettings(Settings left, Settings right, boolean checkClusterUniqueSettings) {
Set<Map.Entry<String, String>> entries0 = left.getAsMap().entrySet();
Map<String, String> entries1 = right.getAsMap();
assertThat("--> left:\n" + left.toDelimitedString('\n') + "\n-->right:\n" + right.toDelimitedString('\n'),
entries0.size(), equalTo(entries1.size()));
for (Map.Entry<String, String> entry : entries0) {
if (clusterUniqueSettings.contains(entry.getKey()) && checkClusterUniqueSettings == false) {
continue;
}
assertThat(entries1, hasEntry(entry.getKey(), entry.getValue()));
}
}
示例2: backupIdxMeta
import org.elasticsearch.common.settings.Settings; //导入方法依赖的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));
}