List of usage examples for com.amazonaws.services.cloudsearchv2.model DomainStatus getDocService
public ServiceEndpoint getDocService()
The service endpoint for updating documents in a search domain.
From source file:com.clicktravel.infrastructure.persistence.aws.cloudsearch.CloudSearchEngine.java
License:Apache License
private void cacheDomainEndpoints() { if (!initialized) { throw new IllegalStateException("CloudSearchEngine not initialized"); }//from ww w . ja v a 2 s .c o m if (!domainEndpointsCached) { final Set<String> managedDomains = new HashSet<>(); for (final DocumentConfiguration documentConfiguration : documentConfigurations.values()) { final String domainName = documentConfigurationHolder.schemaName() + "-" + documentConfiguration.namespace(); managedDomains.add(domainName); } final DescribeDomainsRequest describeDomainsRequest = new DescribeDomainsRequest(); describeDomainsRequest.setDomainNames(managedDomains); final DescribeDomainsResult describeDomainsResult = cloudSearchClient .describeDomains(describeDomainsRequest); final List<DomainStatus> domainStatusList = describeDomainsResult.getDomainStatusList(); if (domainStatusList.size() != managedDomains.size()) { logger.info("Unable to cache CloudSearch document/search endpoints for: " + managedDomains); } else { for (final DomainStatus domainStatus : domainStatusList) { if (domainStatus.isCreated() && !domainStatus.isDeleted()) { final String documentServiceEndpoint = domainStatus.getDocService().getEndpoint(); final String searchServiceEndpoint = domainStatus.getSearchService().getEndpoint(); if (documentServiceEndpoint == null || searchServiceEndpoint == null) { domainEndpointsCached = false; return; } final AmazonCloudSearchDomain documentServiceClient = AmazonCloudSearchDomainClientBuilder .build(awsCredentials, documentServiceEndpoint); final AmazonCloudSearchDomain searchServiceClient = AmazonCloudSearchDomainClientBuilder .build(awsCredentials, searchServiceEndpoint); documentServiceClients.put(domainStatus.getDomainName(), documentServiceClient); searchServiceClients.put(domainStatus.getDomainName(), searchServiceClient); } } domainEndpointsCached = true; } } }
From source file:com.digitalpebble.stormcrawler.aws.bolt.CloudSearchIndexerBolt.java
License:Apache License
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from w w w . j a va 2 s.c o m*/ 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); }
From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.CsDomainDetail.java
License:Open Source License
private void buildUI(DescribeDomainsResult detail) { this.add(primaryScrollPane, BorderLayout.CENTER); if (!detail.getDomainStatusList().isEmpty()) { List<DomainStatus> domains = detail.getDomainStatusList(); DomainStatus domain = domains.get(0); if (domain.getARN() != null) { primaryTableModel.addRow(new Object[] { "Arn", domain.getARN() }); }/* w ww . ja va2 s .co m*/ if (domain.getCreated() != null) { primaryTableModel.addRow(new Object[] { "Created", domain.getCreated() }); } if (domain.getDeleted() != null) { primaryTableModel.addRow(new Object[] { "Deleted", domain.getDeleted() }); } if (domain.getDocService() != null) { primaryTableModel.addRow(new Object[] { "Document Service", domain.getDocService().getEndpoint() }); } if (domain.getDomainId() != null) { primaryTableModel.addRow(new Object[] { "Domain Id", domain.getDomainId() }); } if (domain.getDomainName() != null) { primaryTableModel.addRow(new Object[] { "Domain Name", domain.getDomainName() }); } if (domain.getProcessing() != null) { primaryTableModel.addRow(new Object[] { "Processing", domain.getProcessing() }); } if (domain.getRequiresIndexDocuments() != null) { primaryTableModel.addRow(new Object[] { "Requires Index Document", domain.getProcessing() }); } if (domain.getSearchInstanceCount() != null) { primaryTableModel.addRow(new Object[] { "Search Status Cound", domain.getSearchInstanceCount() }); } if (domain.getSearchInstanceType() != null) { primaryTableModel.addRow(new Object[] { "Search Instance Type", domain.getSearchInstanceType() }); } if (domain.getSearchPartitionCount() != null) { primaryTableModel .addRow(new Object[] { "Search Partition Count", domain.getSearchPartitionCount() }); } if (domain.getSearchService() != null) { primaryTableModel .addRow(new Object[] { "Search Service", domain.getSearchService().getEndpoint() }); } } }
From source file:org.apache.nutch.indexwriter.cloudsearch.CloudSearchIndexWriter.java
License:Apache License
@Override public void open(IndexWriterParams parameters) throws IOException { // LOG.debug("CloudSearchIndexWriter.open() name={} ", name); endpoint = parameters.get(CloudSearchConstants.ENDPOINT); dumpBatchFilesToTemp = parameters.getBoolean(CloudSearchConstants.BATCH_DUMP, false); this.regionName = parameters.get(CloudSearchConstants.REGION); if (StringUtils.isBlank(endpoint) && !dumpBatchFilesToTemp) { String message = "Missing CloudSearch endpoint. Should set it set via -D " + CloudSearchConstants.ENDPOINT + " or in nutch-site.xml"; message += "\n" + describe(); LOG.error(message);// w w w . j a v a 2s . co m throw new RuntimeException(message); } maxDocsInBatch = parameters.getInt(CloudSearchConstants.MAX_DOCS_BATCH, -1); buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('['); if (dumpBatchFilesToTemp) { // only dumping to local file // no more config required return; } 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); }