cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1087728 - in /cassandra/branches/cassandra-0.7: ./ test/distributed/ test/distributed/org/apache/cassandra/ test/distributed/org/apache/cassandra/utils/ test/resources/
Date Fri, 01 Apr 2011 14:52:42 GMT
Author: jbellis
Date: Fri Apr  1 14:52:42 2011
New Revision: 1087728

URL: http://svn.apache.org/viewvc?rev=1087728&view=rev
Log:
upgrade to whirr 0.4
patch by Pavel Yaskevich for CASSANDRA-2265

Modified:
    cassandra/branches/cassandra-0.7/build.xml
    cassandra/branches/cassandra-0.7/test/distributed/README.txt
    cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/CassandraServiceController.java
    cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/utils/BlobUtils.java
    cassandra/branches/cassandra-0.7/test/resources/whirr-default.properties

Modified: cassandra/branches/cassandra-0.7/build.xml
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/build.xml?rev=1087728&r1=1087727&r2=1087728&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/build.xml (original)
+++ cassandra/branches/cassandra-0.7/build.xml Fri Apr  1 14:52:42 2011
@@ -207,8 +207,10 @@
                              sourcesFilesetId="test-dependency-sources" 
                              cacheDependencyRefs="true" 
                              dependencyRefsBuildFile="${build.dir}/test-dependencies.xml">
-        <dependency groupId="org.apache.whirr" artifactId="whirr-core" version="0.3.0-incubating"/>
-        <dependency groupId="org.apache.whirr" artifactId="whirr-cli" version="0.3.0-incubating"/>
+        <dependency groupId="org.apache.whirr" artifactId="whirr-core" version="0.4.0-incubating"/>
+        <dependency groupId="org.apache.whirr" artifactId="whirr-cli" version="0.4.0-incubating"/>
+        <dependency groupId="org.jclouds.provider" artifactId="aws-s3" version="1.0-beta-9b"
/>
+
         <remoteRepository refid="apache"/>
         <remoteRepository refid="central"/>
         <remoteRepository refid="jclouds"/>

Modified: cassandra/branches/cassandra-0.7/test/distributed/README.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/distributed/README.txt?rev=1087728&r1=1087727&r2=1087728&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/distributed/README.txt (original)
+++ cassandra/branches/cassandra-0.7/test/distributed/README.txt Fri Apr  1 14:52:42 2011
@@ -26,7 +26,8 @@ configuration is located at:
 
 An example EC2/S3 whirr configuration would be:
 ###############################################
-whirr.provider=ec2
+whirr.cluster-user=[username]
+whirr.provider=aws-ec2
 whirr.location-id=us-west-1
 whirr.image-id=us-west-1/ami-16f3a253
 whirr.hardware-id=m1.large
@@ -35,7 +36,7 @@ whirr.credential=[EC2 Secret Access Key]
 whirr.private-key-file=${sys:user.home}/.ssh/id_rsa
 whirr.public-key-file=${sys:user.home}/.ssh/id_rsa.pub
 whirr.run-url-base=http://hoodidge.net/scripts/
-whirr.blobstore.provider=s3
+whirr.blobstore.provider=aws-s3
 whirr.blobstore.container=cassandratests
 ###############################################
 

Modified: cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/CassandraServiceController.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/CassandraServiceController.java?rev=1087728&r1=1087727&r2=1087728&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/CassandraServiceController.java
(original)
+++ cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/CassandraServiceController.java
Fri Apr  1 14:52:42 2011
@@ -18,52 +18,41 @@
 
 package org.apache.cassandra;
 
-import java.io.IOException;
 import java.net.InetAddress;
 import java.net.URI;
 import java.util.*;
 
+import com.google.common.base.Predicate;
+
 import org.apache.cassandra.thrift.Cassandra;
-import org.apache.cassandra.thrift.TokenRange;
-import org.apache.cassandra.utils.KeyPair;
 import org.apache.cassandra.utils.BlobUtils;
+import org.apache.cassandra.utils.KeyPair;
 import org.apache.cassandra.utils.Pair;
-
-import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.PropertiesConfiguration;
-
 import org.apache.thrift.TException;
-import org.apache.thrift.protocol.*;
-import org.apache.thrift.transport.*;
-
-import org.apache.whirr.service.Cluster;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.whirr.service.*;
 import org.apache.whirr.service.Cluster.Instance;
-import org.apache.whirr.service.ClusterSpec;
-import org.apache.whirr.service.ComputeServiceContextBuilder;
-import org.apache.whirr.service.Service;
-import org.apache.whirr.service.ServiceFactory;
-import org.apache.whirr.service.cassandra.CassandraService;
 import org.apache.whirr.service.cassandra.CassandraClusterActionHandler;
 import org.apache.whirr.service.jclouds.RunUrlStatement;
 
 import org.jclouds.blobstore.domain.BlobMetadata;
-
 import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.ExecResponse;
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.options.RunScriptOptions;
 import org.jclouds.domain.Credentials;
-import org.jclouds.io.Payload;
 import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.ssh.ExecResponse;
-import static org.jclouds.io.Payloads.newStringPayload;
-
-import com.google.common.base.Predicate;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertThat;
+import static org.jclouds.io.Payloads.newStringPayload;
 
 public class CassandraServiceController
 {
@@ -84,7 +73,7 @@ public class CassandraServiceController
     private boolean     running;
 
     private ClusterSpec         clusterSpec;
-    private CassandraService    service;
+    private Service             service;
     private Cluster             cluster;
     private ComputeService      computeService;
     private Credentials         credentials;
@@ -96,8 +85,7 @@ public class CassandraServiceController
     {
     }
 
-    public Cassandra.Client createClient(InetAddress addr)
-        throws TTransportException, TException
+    public Cassandra.Client createClient(InetAddress addr) throws TException
     {
         TTransport transport    = new TSocket(
                                     addr.getHostAddress(),
@@ -170,10 +158,10 @@ public class CassandraServiceController
             tarball = blob.left;
             config.setProperty(CassandraClusterActionHandler.BIN_TARBALL, blob.right.toURL().toString());
             // TODO: parse the CassandraVersion property file instead
-            config.setProperty(CassandraClusterActionHandler.MAJOR_VERSION, "0.7");
+            config.setProperty(CassandraClusterActionHandler.MAJOR_VERSION, "0.8");
         }
 
-        service = (CassandraService)new ServiceFactory().create(clusterSpec.getServiceName());
+        service = new ServiceFactory().create(clusterSpec.getServiceName());
         cluster = service.launchCluster(clusterSpec);
         computeService = ComputeServiceContextBuilder.build(clusterSpec).getComputeService();
         hosts = new ArrayList<InetAddress>();

Modified: cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/utils/BlobUtils.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/utils/BlobUtils.java?rev=1087728&r1=1087727&r2=1087728&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/utils/BlobUtils.java
(original)
+++ cassandra/branches/cassandra-0.7/test/distributed/org/apache/cassandra/utils/BlobUtils.java
Fri Apr  1 14:52:42 2011
@@ -19,24 +19,26 @@
 package org.apache.cassandra.utils;
 
 import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.net.URI;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 
+import com.google.common.io.Files;
 import org.apache.commons.configuration.Configuration;
 
 import org.apache.whirr.service.ClusterSpec;
 
-import org.jclouds.blobstore.BlobStore;
 import org.jclouds.blobstore.BlobStoreContext;
 import org.jclouds.blobstore.BlobStoreContextFactory;
-import org.jclouds.blobstore.domain.BlobMetadata;
 import org.jclouds.blobstore.InputStreamMap;
+import org.jclouds.blobstore.domain.BlobMetadata;
 
-import org.jclouds.aws.s3.S3Client;
-import org.jclouds.aws.s3.S3AsyncClient;
-import org.jclouds.aws.s3.domain.AccessControlList;
-import org.jclouds.aws.s3.domain.CannedAccessPolicy;
-
-import org.jclouds.rest.RestContext;
+import org.jclouds.s3.S3AsyncClient;
+import org.jclouds.s3.S3Client;
+import org.jclouds.s3.domain.AccessControlList;
+import org.jclouds.s3.domain.CannedAccessPolicy;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -77,24 +79,63 @@ public final class BlobUtils
         File file = new File(filename);
         String container = getContainer(config);
         String provider = getProvider(config);
+
+        // blob name and checksum of the file
         String blobName = System.nanoTime() + "/" + file.getName();
+        String blobNameChecksum = blobName + ".md5";
+
         BlobStoreContext context = getContext(config, spec);
+
+        File checksumFile;
+
+        try
+        {
+            checksumFile = File.createTempFile("dtchecksum", "md5");
+            checksumFile.deleteOnExit();
+
+            FileWriter checksumWriter = new FileWriter(checksumFile);
+
+            String checksum = FBUtilities.bytesToHex(Files.getDigest(file, MessageDigest.getInstance("MD5")));
+
+            checksumWriter.write(String.format("%s  %s", checksum, file.getName()));
+            checksumWriter.close();
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("Can't create a checksum of the file: " + filename);
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            throw new RuntimeException(e.getMessage());
+        }
+
         try
         {
             InputStreamMap map = context.createInputStreamMap(container);
+
             map.putFile(blobName, file);
+            map.putFile(blobNameChecksum, checksumFile);
+
             // TODO: magic! in order to expose the blob as public, we need to dive into provider
specific APIs
             // the hope is that permissions are encapsulated in jclouds in the future
-            if (provider.equals("s3"))
+            if (provider.contains("s3"))
             {
                 S3Client sss = context.<S3Client,S3AsyncClient>getProviderSpecificContext().getApi();
                 String ownerId = sss.getObjectACL(container, blobName).getOwner().getId();
+
                 sss.putObjectACL(container,
                                  blobName,
                                  AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PUBLIC_READ,
ownerId));
+
+                sss.putObjectACL(container,
+                                 blobNameChecksum,
+                                 AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PUBLIC_READ,
ownerId));
             }
             else
+            {
                 LOG.warn(provider + " may not be properly supported for tarball transfer.");
+            }
+
             // resolve the full URI of the blob (see http://code.google.com/p/jclouds/issues/detail?id=431)
             BlobMetadata blob = context.getBlobStore().blobMetadata(container, blobName);
             URI uri = context.getProviderSpecificContext().getEndpoint().resolve("/" + container
+ "/" + blob.getName());

Modified: cassandra/branches/cassandra-0.7/test/resources/whirr-default.properties
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/resources/whirr-default.properties?rev=1087728&r1=1087727&r2=1087728&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/resources/whirr-default.properties (original)
+++ cassandra/branches/cassandra-0.7/test/resources/whirr-default.properties Fri Apr  1 14:52:42
2011
@@ -17,5 +17,6 @@
 #
 whirr.service-name=cassandra
 whirr.cluster-name=cassandra_test
+whirr.cluster-user=app
 whirr.instance-templates=4 cassandra
-whirr.version=0.3.0-incubating-SNAPSHOT
+whirr.version=0.4.0-incubating



Mime
View raw message