Search in sources :

Example 1 with DomainStatus

use of com.amazonaws.services.cloudsearchv2.model.DomainStatus in project Synapse-Stack-Builder by Sage-Bionetworks.

the class StackConfigurationSetup method initialize.

public void initialize(AmazonClientFactory factory, InputConfiguration config, GeneratedResources resources) {
    if (factory == null)
        throw new IllegalArgumentException("AmazonClientFactory cannot be null");
    if (config == null)
        throw new IllegalArgumentException("Config cannot be null");
    if (resources == null)
        throw new IllegalArgumentException("GeneratedResources cannot be null");
    if (resources.getIdGeneratorDatabase() == null)
        throw new IllegalArgumentException("GeneratedResources.getIdGeneratorDatabase() cannot be null");
    if (resources.getIdGeneratorDatabase().getEndpoint() == null)
        throw new IllegalArgumentException("GeneratedResources.getIdGeneratorDatabase().getEndpoint() cannot be null");
    if (resources.getStackInstancesDatabase() == null)
        throw new IllegalArgumentException("GeneratedResources.getStackInstancesDatabase() cannot be null");
    if (resources.getStackInstancesDatabase().getEndpoint() == null)
        throw new IllegalArgumentException("GeneratedResources.getStackInstancesDatabase().getEndpoint() cannot be null");
    if (resources.getSearchDomain() == null)
        throw new IllegalArgumentException("GeneratedResources.getSearchDomain() cannot be null");
    DomainStatus searchStatus = resources.getSearchDomain();
    if (resources.getSearchDomain().getSearchService() == null || searchStatus.getSearchService().getEndpoint() == null) {
        throw new IllegalArgumentException(String.format("Do not have an endpoint for Search domain: '%1$s' created: '%2$s', processing: '%3$s'", searchStatus.getDomainName(), searchStatus.getCreated(), searchStatus.getProcessing()));
    }
    if (resources.getSearchDomain().getDocService() == null || resources.getSearchDomain().getDocService().getEndpoint() == null) {
        throw new IllegalArgumentException(String.format("Do not have an endpoint for Search documents: '%1$s' created: '%2$s', processing: '%3$s'", searchStatus.getDomainName(), searchStatus.getCreated(), searchStatus.getProcessing()));
    }
    this.client = factory.createS3Client();
    this.config = config;
    this.resources = resources;
}
Also used : DomainStatus(com.amazonaws.services.cloudsearchv2.model.DomainStatus)

Example 2 with DomainStatus

use of com.amazonaws.services.cloudsearchv2.model.DomainStatus in project Synapse-Stack-Builder by Sage-Bionetworks.

the class TestHelper method createTestResources.

/**
 * Create GeneratedResources that can be used for a test.
 *
 * @param config
 * @return
 */
public static GeneratedResources createTestResources(InputConfiguration config) {
    GeneratedResources resources = new GeneratedResources();
    resources.setIdGeneratorDatabase(new DBInstance().withDBInstanceIdentifier(config.getIdGeneratorDatabaseIdentifier()).withEndpoint(new Endpoint().withAddress("id-gen-db.someplace.com")));
    resources.setStackInstancesDatabase(new DBInstance().withDBInstanceIdentifier(config.getStackInstanceDatabaseIdentifier()).withEndpoint(new Endpoint().withAddress("stack-instance-db.someplace.com")));
    resources.setSearchDomain(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("search-service.someplace.com")));
    resources.getSearchDomain().setDocService(new ServiceEndpoint().withEndpoint("doc-service.someplace.com"));
    resources.setSslCertificate(StackEnvironmentType.REPO, new ServerCertificateMetadata().withArn("ssl:arn:123"));
    resources.setSslCertificate(StackEnvironmentType.WORKERS, new ServerCertificateMetadata().withArn("ssl:arn:123"));
    resources.setSslCertificate(StackEnvironmentType.PORTAL, new ServerCertificateMetadata().withArn("ssl:arn:456"));
    resources.setACMCertificateArn(StackEnvironmentType.PORTAL, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-123456789012");
    resources.setACMCertificateArn(StackEnvironmentType.REPO, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-223456789012");
    resources.setACMCertificateArn(StackEnvironmentType.WORKERS, "arn:aws:acm:us-east1:123456789012:certificate/12345678-1234-1234-1234-323456789012");
    resources.setPortalApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_PORTAL)));
    resources.setRepoApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_REPO)));
    resources.setWorkersApplicationVersion(new ApplicationVersionDescription().withVersionLabel(config.getVersionLabel(PREFIX_WORKERS)));
    resources.setStackKeyPair(new KeyPairInfo().withKeyName(config.getStackKeyPairName()));
    // Add tables database instances
    List<DBInstance> tablesInstances = new LinkedList<DBInstance>();
    tablesInstances.add(new DBInstance().withEndpoint(new Endpoint().withAddress("tables.endpoint.one")));
    tablesInstances.add(new DBInstance().withEndpoint(new Endpoint().withAddress("tables.endpoint.two")));
    resources.setStackInstanceTablesDatabases(tablesInstances);
    return resources;
}
Also used : ServerCertificateMetadata(com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata) ApplicationVersionDescription(com.amazonaws.services.elasticbeanstalk.model.ApplicationVersionDescription) DBInstance(com.amazonaws.services.rds.model.DBInstance) ServiceEndpoint(com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint) Endpoint(com.amazonaws.services.rds.model.Endpoint) KeyPairInfo(com.amazonaws.services.ec2.model.KeyPairInfo) DomainStatus(com.amazonaws.services.cloudsearchv2.model.DomainStatus) ServiceEndpoint(com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint) LinkedList(java.util.LinkedList)

Example 3 with DomainStatus

use of com.amazonaws.services.cloudsearchv2.model.DomainStatus in project nutch by apache.

the class CloudSearchIndexWriter method open.

@Override
public void open(Configuration conf, String name) throws IOException {
    LOG.debug("CloudSearchIndexWriter.open() name={} ", name);
    maxDocsInBatch = conf.getInt(CloudSearchConstants.MAX_DOCS_BATCH, -1);
    buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('[');
    dumpBatchFilesToTemp = conf.getBoolean(CloudSearchConstants.BATCH_DUMP, false);
    if (dumpBatchFilesToTemp) {
        // no more config required
        return;
    }
    String endpoint = conf.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);
}
Also used : DescribeDomainsResult(com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult) DescribeDomainsRequest(com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest) DescribeIndexFieldsRequest(com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsRequest) IndexFieldStatus(com.amazonaws.services.cloudsearchv2.model.IndexFieldStatus) AmazonCloudSearchClient(com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient) AmazonCloudSearchDomainClient(com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient) DomainStatus(com.amazonaws.services.cloudsearchv2.model.DomainStatus) DescribeIndexFieldsResult(com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsResult)

Aggregations

DomainStatus (com.amazonaws.services.cloudsearchv2.model.DomainStatus)3 AmazonCloudSearchDomainClient (com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient)1 AmazonCloudSearchClient (com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient)1 DescribeDomainsRequest (com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest)1 DescribeDomainsResult (com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult)1 DescribeIndexFieldsRequest (com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsRequest)1 DescribeIndexFieldsResult (com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsResult)1 IndexFieldStatus (com.amazonaws.services.cloudsearchv2.model.IndexFieldStatus)1 ServiceEndpoint (com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint)1 KeyPairInfo (com.amazonaws.services.ec2.model.KeyPairInfo)1 ApplicationVersionDescription (com.amazonaws.services.elasticbeanstalk.model.ApplicationVersionDescription)1 ServerCertificateMetadata (com.amazonaws.services.identitymanagement.model.ServerCertificateMetadata)1 DBInstance (com.amazonaws.services.rds.model.DBInstance)1 Endpoint (com.amazonaws.services.rds.model.Endpoint)1 LinkedList (java.util.LinkedList)1