當前位置: 首頁>>代碼示例>>Java>>正文


Java Settings.getAsMap方法代碼示例

本文整理匯總了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()));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:InternalTestClusterTests.java

示例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));
}
 
開發者ID:jiashiwen,項目名稱:elasticbak,代碼行數:62,代碼來源:BackupEsIndex.java


注:本文中的org.elasticsearch.common.settings.Settings.getAsMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。