com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient Java Examples

The following examples show how to use com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Handler.java    From Building-Serverless-Architectures with MIT License 4 votes vote down vote up
@Inject
public Handler setAmazonCloudSearchDomainClient(AmazonCloudSearchDomainClient amazonCloudSearchDomainClient) {
    this.amazonCloudSearchDomainClient = amazonCloudSearchDomainClient;
    this.amazonCloudSearchDomainClient.setEndpoint(System.getenv("CloudSearchDomain"));
    return this;
}
 
Example #2
Source File: Handler.java    From Building-Serverless-Architectures with MIT License 4 votes vote down vote up
@Inject
public Handler setAmazonCloudSearchDomainClient(AmazonCloudSearchDomainClient amazonCloudSearchDomainClient) {
    this.amazonCloudSearchDomainClient = amazonCloudSearchDomainClient;
    this.amazonCloudSearchDomainClient.setEndpoint(System.getenv("CloudSearchDomain"));
    return this;
}
 
Example #3
Source File: Handler.java    From Building-Serverless-Architectures with MIT License 4 votes vote down vote up
@Inject
public Handler setAmazonCloudSearchDomainClient(AmazonCloudSearchDomainClient amazonCloudSearchDomainClient) {
    this.amazonCloudSearchDomainClient = amazonCloudSearchDomainClient;
    this.amazonCloudSearchDomainClient.setEndpoint(System.getenv("CloudSearchDomain"));
    return this;
}
 
Example #4
Source File: AmazonCloudSearchDomainClientBuilder.java    From Cheddar with Apache License 2.0 4 votes vote down vote up
public static AmazonCloudSearchDomain build(final String endpoint) {
    final AmazonCloudSearchDomain amazonCloudSearchDomain = new AmazonCloudSearchDomainClient();
    amazonCloudSearchDomain.setEndpoint(endpoint);
    return amazonCloudSearchDomain;
}
 
Example #5
Source File: CloudSearchIndexerBolt.java    From storm-crawler with Apache License 2.0 4 votes vote down vote up
@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);
}