本文整理汇总了Java中com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient.setRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonCloudSearchClient.setRegion方法的具体用法?Java AmazonCloudSearchClient.setRegion怎么用?Java AmazonCloudSearchClient.setRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient
的用法示例。
在下文中一共展示了AmazonCloudSearchClient.setRegion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanCloudSearch
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient; //导入方法依赖的package包/类
/**
* Collect data for CloudSearch.
*
* @param stats
* current statistics object.
* @param account
* currently used credentials object.
* @param region
* currently used aws region.
*/
public static void scanCloudSearch(AwsStats stats, AwsAccount account, Regions region) {
LOG.debug("Scan for CloudSearch in region " + region.getName() + " in account " + account.getAccountId());
try {
AmazonCloudSearchClient cs = new AmazonCloudSearchClient(account.getCredentials());
cs.setRegion(Region.getRegion(region));
int totalDomains = 0;
for (DomainStatus ds : cs.describeDomains().getDomainStatusList()) {
AwsResource res = new AwsResource(ds.getDomainName(), account.getAccountId(), AwsResourceType.CloudSearch, region);
res.addInfo("Endpoint", ds.getSearchService().getEndpoint());
res.addInfo("SearchInstanceType", ds.getSearchInstanceType());
res.addInfo("SearchInstanceCount", ds.getSearchInstanceCount());
res.addInfo("ARN", ds.getARN());
stats.add(res);
totalDomains++;
}
LOG.info(totalDomains + " CloudSearch domains in region " + region.getName() + " in account " + account.getAccountId());
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().contains("AccessDenied")) {
LOG.info("Access denied for CloudSearch in region " + region.getName() + " in account " + account.getAccountId());
} else {
LOG.error("Exception of CloudSearch: " + ase.getMessage());
}
} catch (Exception ex) {
LOG.error("Exception of CloudSearch: " + ex.getMessage());
}
}
示例2: open
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient; //导入方法依赖的package包/类
@Override
public void open(JobConf job, String name) throws IOException {
LOG.debug("CloudSearchIndexWriter.open() name={} ", name);
maxDocsInBatch = job.getInt(CloudSearchConstants.MAX_DOCS_BATCH, -1);
buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('[');
dumpBatchFilesToTemp = job.getBoolean(CloudSearchConstants.BATCH_DUMP,
false);
if (dumpBatchFilesToTemp) {
// only dumping to local file
// no more config required
return;
}
String endpoint = job.get(CloudSearchConstants.ENDPOINT);
if (StringUtils.isBlank(endpoint)) {
throw new RuntimeException("endpoint not set for CloudSearch");
}
AmazonCloudSearchClient cl = new AmazonCloudSearchClient();
if (StringUtils.isNotBlank(regionName)) {
cl.setRegion(RegionUtils.getRegion(regionName));
}
String domainName = null;
// retrieve the domain name
DescribeDomainsResult domains = cl
.describeDomains(new DescribeDomainsRequest());
Iterator<DomainStatus> dsiter = domains.getDomainStatusList().iterator();
while (dsiter.hasNext()) {
DomainStatus ds = dsiter.next();
if (ds.getDocService().getEndpoint().equals(endpoint)) {
domainName = ds.getDomainName();
break;
}
}
// check domain name
if (StringUtils.isBlank(domainName)) {
throw new RuntimeException(
"No domain name found for CloudSearch endpoint");
}
DescribeIndexFieldsResult indexDescription = cl.describeIndexFields(
new DescribeIndexFieldsRequest().withDomainName(domainName));
for (IndexFieldStatus ifs : indexDescription.getIndexFields()) {
String indexname = ifs.getOptions().getIndexFieldName();
String indextype = ifs.getOptions().getIndexFieldType();
LOG.info("CloudSearch index name {} of type {}", indexname, indextype);
csfields.put(indexname, indextype);
}
client = new AmazonCloudSearchDomainClient();
client.setEndpoint(endpoint);
}
示例3: prepare
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void prepare(Map conf, TopologyContext context,
OutputCollector collector) {
super.prepare(conf, context, collector);
_collector = collector;
this.eventCounter = context.registerMetric("CloudSearchIndexer",
new MultiCountMetric(), 10);
maxTimeBuffered = ConfUtils.getInt(conf,
CloudSearchConstants.MAX_TIME_BUFFERED, 10);
maxDocsInBatch = ConfUtils.getInt(conf,
CloudSearchConstants.MAX_DOCS_BATCH, -1);
buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('[');
dumpBatchFilesToTemp = ConfUtils.getBoolean(conf,
"cloudsearch.batch.dump", false);
if (dumpBatchFilesToTemp) {
// only dumping to local file
// no more config required
return;
}
String endpoint = ConfUtils.getString(conf, "cloudsearch.endpoint");
if (StringUtils.isBlank(endpoint)) {
String message = "Missing CloudSearch endpoint";
LOG.error(message);
throw new RuntimeException(message);
}
String regionName = ConfUtils.getString(conf,
CloudSearchConstants.REGION);
AmazonCloudSearchClient cl = new AmazonCloudSearchClient();
if (StringUtils.isNotBlank(regionName)) {
cl.setRegion(RegionUtils.getRegion(regionName));
}
String domainName = null;
// retrieve the domain name
DescribeDomainsResult domains = cl
.describeDomains(new DescribeDomainsRequest());
Iterator<DomainStatus> dsiter = domains.getDomainStatusList()
.iterator();
while (dsiter.hasNext()) {
DomainStatus ds = dsiter.next();
if (ds.getDocService().getEndpoint().equals(endpoint)) {
domainName = ds.getDomainName();
break;
}
}
// check domain name
if (StringUtils.isBlank(domainName)) {
throw new RuntimeException(
"No domain name found for CloudSearch endpoint");
}
DescribeIndexFieldsResult indexDescription = cl
.describeIndexFields(new DescribeIndexFieldsRequest()
.withDomainName(domainName));
for (IndexFieldStatus ifs : indexDescription.getIndexFields()) {
String indexname = ifs.getOptions().getIndexFieldName();
String indextype = ifs.getOptions().getIndexFieldType();
LOG.info("CloudSearch index name {} of type {}", indexname,
indextype);
csfields.put(indexname, indextype);
}
client = new AmazonCloudSearchDomainClient();
client.setEndpoint(endpoint);
}