]> source.dussan.org Git - archiva.git/commitdiff
some fixes for cassandra
authorOlivier Lamy <olamy@apache.org>
Fri, 6 Sep 2013 03:14:09 +0000 (03:14 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 6 Sep 2013 03:14:09 +0000 (03:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1520481 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/metadata-store-cassandra/pom.xml
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java

index 7c15fa9924a2d76c3dfd646d52478399a39fec68..68a87de0ec1cd341fa1bbd5412e72168ef993e66 100644 (file)
@@ -31,6 +31,7 @@
   <name>Archiva Core Plugins :: Cassandra JPA Storage for Metadata</name>
 
   <properties>
+    <!-- upgrade need a new astyanax release > 1.56.42 see https://github.com/Netflix/astyanax/issues/352 -->
     <cassandraVersion>1.2.5</cassandraVersion>
     <astyanax.version>1.56.42</astyanax.version>
   </properties>
       </exclusions>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.thrift</groupId>
+      <artifactId>libthrift</artifactId>
+      <version>0.9.1</version>
+    </dependency>
+
 
     <dependency>
       <groupId>org.springframework</groupId>
           </execution>
         </executions>
       </plugin>
-      <!-- TODO use dynamic port -->
-
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>cassandra-maven-plugin</artifactId>
index ad529aaabbb7d0633ba861a02bb9548585f0ccd7..2373313d39994e45aa039a1f482b3c70117a75dc 100644 (file)
@@ -838,7 +838,7 @@ public class CassandraMetadataRepository
             artifactMetadataModel.setArtifactMetadataModelId(
                 new ArtifactMetadataModel.KeyBuilder().withId( versionMetadata.getId() ).withRepositoryId(
                     repositoryId ).withNamespace( namespaceId ).withProjectVersion(
-                    versionMetadata.getVersion() ).build() );
+                    versionMetadata.getVersion() ).withProject( projectId ).build() );
             artifactMetadataModel.setRepositoryId( repositoryId );
             artifactMetadataModel.setNamespace( namespaceId );
             artifactMetadataModel.setProject( projectId );
@@ -1295,35 +1295,7 @@ public class CassandraMetadataRepository
             }
         } );
         getArtifactMetadataModelEntityManager().remove( artifactMetadataModels );
-        /*
-        getMetadataFacetModelEntityManager().visitAll( new Function<MetadataFacetModel, Boolean>()
-        {
-            @Override
-            public Boolean apply( MetadataFacetModel metadataFacetModel )
-            {
-                if ( metadataFacetModel != null )
-                {
-                    ArtifactMetadataModel artifactMetadataModel = metadataFacetModel.getArtifactMetadataModel();
-                    if ( artifactMetadataModel != null )
-                    {
-                        if ( StringUtils.equals( repositoryId, artifactMetadataModel.getRepositoryId() )
-                            && StringUtils.equals( namespace, artifactMetadataModel.getNamespace() )
-                            && StringUtils.equals( project, artifactMetadataModel.getProject() ) && StringUtils.equals(
-                            version, artifactMetadataModel.getVersion() ) )
-                        {
-                            if ( StringUtils.equals( metadataFacetModel.getFacetId(), metadataFacet.getFacetId() )
-                                && StringUtils.equals( metadataFacetModel.getName(), metadataFacet.getName() ) )
-                            {
-                                metadataFacetModels.add( metadataFacetModel );
-                            }
-                        }
-                    }
-                }
-                return Boolean.TRUE;
-            }
-        } );
-        getMetadataFacetModelEntityManager().remove( metadataFacetModels );
-        */
+
     }
 
 
@@ -1521,25 +1493,7 @@ public class CassandraMetadataRepository
                 return Boolean.TRUE;
             }
         } );
-        /*
 
-        getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
-        {
-            @Override
-            public Boolean apply( ArtifactMetadataModel artifactMetadataModel )
-            {
-                if ( artifactMetadataModel != null )
-                {
-                    if ( StringUtils.equals( repoId, artifactMetadataModel.getRepositoryId() ) && StringUtils.equals(
-                        namespace, artifactMetadataModel.getNamespace() ) )
-                    {
-                        projects.add( artifactMetadataModel.getProject() );
-                    }
-                }
-                return Boolean.TRUE;
-            }
-        } );
-        */
         return projects;
     }
 
index aa635e9ff94b64feca8318db174ec805f22f7f38..c9960aeda05ad088105c64e9756806aba9127a1a 100644 (file)
@@ -323,8 +323,8 @@ public class ArtifactMetadataModel
         {
             //repositoryId + namespaceId + project + projectVersion + id
             // FIXME add some controls
-            return this.repositoryId + "-" + this.namespaceId + "-" + this.project + "-" + this.projectVersion + "-"
-                + this.id;
+            long hash = this.repositoryId.hashCode()  + this.namespaceId.hashCode()  + this.project.hashCode()  + this.projectVersion.hashCode() + this.id.hashCode();
+            return Long.toString( hash );
         }
     }
 
index 545787fbac49fd9e25558cc813a6d33774d60318..2cb101521b5e4cfe9b16153e1b9e49f2e6c70b25 100644 (file)
@@ -33,22 +33,22 @@ public class MetadataFacetModel
 {
     // id is repositoryId + namespaceId + projectId + facetId + name + mapKey
     @Id
-    @Column( name = "id" )
+    @Column(name = "id")
     private String id;
 
-    @Column( name = "artifactMetadataModel" )
+    @Column(name = "artifactMetadataModel")
     private ArtifactMetadataModel artifactMetadataModel;
 
-    @Column( name = "facetId" )
+    @Column(name = "facetId")
     private String facetId;
 
-    @Column( name = "name" )
+    @Column(name = "name")
     private String name;
 
-    @Column( name = "key" )
+    @Column(name = "key")
     private String key;
 
-    @Column( name = "value" )
+    @Column(name = "value")
     private String value;
 
     public MetadataFacetModel()
@@ -220,10 +220,16 @@ public class MetadataFacetModel
             // FIXME add some controls
             // getArtifactMetadataModelId can have no namespace, no project and no projectid for statistics
             // only repositoryId with artifactMetadataModel
-            return ( this.artifactMetadataModel == null
-                ? this.repositoryId
-                : this.artifactMetadataModel.getArtifactMetadataModelId() ) + "-" + this.facetId + "-" + this.name + "-"
-                + this.key;
+            long hash =
+                ( this.artifactMetadataModel == null
+                ? this.repositoryId.hashCode()
+                : Long.parseLong( this.artifactMetadataModel.getArtifactMetadataModelId() ) )
+                + this.facetId.hashCode()
+                + ( this.name == null ? 0 : this.name.hashCode() )
+                + ( this.key == null ? 0 : this.key.hashCode() );
+
+            String hashStr = Long.toString( hash );
+            return hashStr;
         }
     }
 }
index aaa9fc41ead12eb8837e3993f027b53002917ba3..0a4adacaeff52e4ba0de999498c95cc6f984982d 100644 (file)
@@ -43,16 +43,16 @@ public class ProjectVersionMetadataModel
     @Id
     private String rowId;
 
-    @Column( name = "namespace" )
+    @Column(name = "namespace")
     private Namespace namespace;
 
     /**
      * id is the version
      */
-    @Column( name = "id" )
+    @Column(name = "id")
     private String id;
 
-    @Column( name = "projectId" )
+    @Column(name = "projectId")
     private String projectId;
 
     @Column(name = "url")
@@ -346,9 +346,11 @@ public class ProjectVersionMetadataModel
         public String build()
         {
             // FIXME add some controls
-            return this.repositoryId + "-" + this.namespace + "-" + this.projectId + ( this.id == null
-                ? ""
-                : "-" + this.id );
+            long hash =
+                this.repositoryId.hashCode() + this.namespace.hashCode() + this.projectId.hashCode() + ( this.id == null
+                    ? 0
+                    : +this.id.hashCode() );
+            return Long.toString( hash );
         }
     }
 }