package me.tango.devops.task;


import me.tango.devops.google.StorageManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.UUID;

/** Upload and download data to test the speed. */
public class GoogleSDKUploadTask extends AbstractUploadTask {
    /** log. */
    private static final Logger LOGGER = LoggerFactory.getLogger(GoogleSDKUploadTask.class);

    /** Constructor. */
    public GoogleSDKUploadTask(final String region, final String bucket, final byte[] data) {
        super(region, bucket, data);
    }

    /**
     * Upload and download.
     */
    @Override
    public void run() {
        final String key = UUID.randomUUID().toString();

        long start = System.currentTimeMillis();

        final boolean success = StorageManager.putBytes(bucket, key, data);

        long finish = System.currentTimeMillis();

        final long uploadTime = finish - start;

        if (!success) {
            result = new UploadTaskResult(success, uploadTime, 0);
            return;
        }

        start = System.currentTimeMillis();

        final byte[] returnData = StorageManager.getBytes(bucket, key);

        finish = System.currentTimeMillis();

        final long downloadTime = finish - start;

        LOGGER.debug("Download task to {} finished in {} ms", bucket, downloadTime);

        result =
            new UploadTaskResult(success && returnData != null && Arrays.equals(data, returnData),
                uploadTime, downloadTime);

        StorageManager.deleteBytes(bucket, key);

        LOGGER.debug("Delete task to {} finished", bucket);
    }

}

@@ -1,8 +1,616 @@
+/**%0A *  Copyright 2015 TangoMe Inc.%0A *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  you may not use this file except in compliance with the License.%0A *  You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0A%0A
 package 

Update GoogleSDKUploadTask.java