Package com.streamreduce.util

Examples of com.streamreduce.util.AWSClient


                .authType(AuthType.USERNAME_PASSWORD)
                .build();

        connectionService.createConnection(connection);

        AWSClient awsClient = new AWSClient(connection);
        int realInventoryItemCount = Iterables.size(Iterables.concat(awsClient.getEC2Instances(),
                awsClient.getS3BucketsAsJson()));
        List<InventoryItem> internalInventoryItems = inventoryService.getInventoryItems(connection);
        int iterationCount = 0;

        while (realInventoryItemCount != internalInventoryItems.size()) {
            Thread.sleep(10000);
View Full Code Here


        awsConnection.setAccount(testAccount);
        awsConnection.setUser(testUser);

        connectionService.createConnection(awsConnection);

        AWSClient awsClient = new AWSClient(awsConnection);
        Set<? extends StorageMetadata> buckets = awsClient.getS3Buckets();
        Set<String> bucketNames = new HashSet<>();
        for (StorageMetadata bucket : buckets) {
            bucketNames.add(bucket.getName());
        }
        assertTrue(bucketNames.contains(actualBucketName));
View Full Code Here

                .dataTypes(OutboundDataType.PROCESSED)
                .namespace(bucketName)
                .build();

        //Do something that makes the bucket appear
        AWSClient awsClient = new AWSClient(preexistingOutboundConfig);
        awsClient.createBucket(preexistingOutboundConfig);
    }
View Full Code Here

        ExternalIntegrationClient externalClient = null;
        try {
            for (OutboundConfiguration outboundConfiguration : outboundConfigurations) {
                if (outboundConfiguration.getProtocol().equals("s3")) {
                    AWSClient awsClient = new AWSClient(outboundConfiguration);
                    externalClient = awsClient;
                    externalClient.validateConnection();
                    try {
                        awsClient.createBucket(outboundConfiguration);
                    } catch (IllegalStateException e) { //thrown when a bucket name is already taken
                        throw new InvalidOutboundConfigurationException(e.getMessage(), e);
                    }
                } else if (outboundConfiguration.getProtocol().equals("webhdfs")) {
                    externalClient = new WebHDFSClient(outboundConfiguration);
View Full Code Here

    public void destroyComputeInstance(InventoryItem inventoryItem) throws InvalidCredentialsException {
        Preconditions.checkNotNull(inventoryItem, "inventoryItem cannot be null.");
        Preconditions.checkArgument(inventoryItem.getType().equals(Constants.COMPUTE_INSTANCE_TYPE),
                                    "Inventory item of type '" + inventoryItem.getType() + "' cannot be destroyed.");

        AWSClient client = (AWSClient)getClient(inventoryItem.getConnection());

        logger.debug("Terminating node: " + inventoryItem.getExternalId());

        BasicDBObject payload = getInventoryItemPayload(inventoryItem);
        String jcloudsNodeId = payload.getString("id");
        NodeMetadata nodeMetadata = client.getEC2Instance(jcloudsNodeId);

        if (nodeMetadata.getStatus().equals(NodeMetadata.Status.TERMINATED)) {
            return;
        }

        EventId eventId;

        if (client.destroyEC2Instance(jcloudsNodeId)) {
            eventId = EventId.CLOUD_INVENTORY_ITEM_TERMINATE;
        } else {
            // TODO: Handle this issue but it can be a false positive if the time it takes surpasses the time we wait
            eventId = EventId.CLOUD_INVENTORY_ITEM_TERMINATE_FAILURE;
        }
View Full Code Here

            }
        }

        if (externalType.equals(ComputeType.NODE.toString())) {
            name = json.getString("name");
            AWSClient client = null;
            try {
                client = new AWSClient(inventoryItem.getConnection());
                Set<Tag> ec2Tags = client.getEC2InstanceTags(externalId);

                // Handle adding new hashtags based on the EC2 tags and the instance name
                for (Tag tag : ec2Tags) {
                    String key = tag.getKey();
                    String value = tag.getValue();

                    if (key.equals("Name")) {
                        if (value.length() > 0) {
                            name = value;
                        }
                    } else {
                        inventoryItem.addHashtag(key + "=" + value);
                    }
                }
            } finally {
                if (client != null) {
                    client.cleanUp();
                }
            }

            internalType = Constants.COMPUTE_INSTANCE_TYPE;
        } else {
View Full Code Here

            ec2CloudWatchMetricNames.put(EC2Constants.MetricName.DISK_WRITE_OPS, Unit.COUNT);
            ec2CloudWatchMetricNames.put(EC2Constants.MetricName.NETWORK_IN, Unit.BYTES);
            ec2CloudWatchMetricNames.put(EC2Constants.MetricName.NETWORK_OUT, Unit.BYTES);
        }

        try (RestContext<CloudWatchApi, CloudWatchAsyncApi> context = new AWSClient(connection).getCloudWatchServiceContext()) {
            CloudWatchApi cloudWatchClient = context.getApi();
            List<InventoryItem> inventoryItems = getInventoryItems(connection);
            String metricNamespace = Namespaces.EC2;
            Calendar cal = Calendar.getInstance();
            Date endTime = new Date();
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public AWSClient getClient(Connection connection) {
        return new AWSClient(connection);
    }
View Full Code Here

        }
    }

    private void sendPayload(String key, byte[] payload) throws OutboundStorageException {
        try {
            AWSClient awsClient = new AWSClient(outboundConfiguration);
            String result = awsClient.pushToS3(outboundConfiguration, key, payload);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("rawMessage sent to S3 identified by: " + result);
            }
        } catch (Exception e) {
            throw new OutboundStorageException(e.getMessage(), e);
View Full Code Here

        List<String> processedKeys = new ArrayList<>();
        List<JSONObject> externalInventoryItems;
        ExternalIntegrationClient client = getClient(connection);

        if (client instanceof AWSClient) {
            AWSClient awsClient = null;
            try {
                awsClient = new AWSClient(connection);
                // Get the EC2 inventory items
                externalInventoryItems = (awsClient.getEC2Instances());
                // Get the S3 inventory items
                externalInventoryItems.addAll(awsClient.getS3BucketsAsJson());
            } finally {
                if (awsClient != null) {
                    awsClient.cleanUp();
                }
            }
        } else if (client instanceof GitHubClient) {
            externalInventoryItems = ((GitHubClient) client).getRepositories();
        } else if (client instanceof GoogleAnalyticsClient) {
View Full Code Here

TOP

Related Classes of com.streamreduce.util.AWSClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.