From: Olivier Lamy Date: Fri, 6 Sep 2013 03:14:09 +0000 (+0000) Subject: some fixes for cassandra X-Git-Tag: archiva-2.0.0-RC1~270 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=726328e7064f59582d9900e200fa37d6a836331c;p=archiva.git some fixes for cassandra git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1520481 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/plugins/metadata-store-cassandra/pom.xml b/archiva-modules/plugins/metadata-store-cassandra/pom.xml index 7c15fa992..68a87de0e 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/pom.xml +++ b/archiva-modules/plugins/metadata-store-cassandra/pom.xml @@ -31,6 +31,7 @@ Archiva Core Plugins :: Cassandra JPA Storage for Metadata + 1.2.5 1.56.42 @@ -161,6 +162,12 @@ + + org.apache.thrift + libthrift + 0.9.1 + + org.springframework @@ -264,8 +271,6 @@ - - org.codehaus.mojo cassandra-maven-plugin diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java index ad529aaab..2373313d3 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java @@ -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() - { - @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() - { - @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; } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java index aa635e9ff..c9960aeda 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java @@ -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 ); } } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java index 545787fba..2cb101521 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java @@ -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; } } } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java index aaa9fc41e..0a4adacae 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java @@ -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 ); } } }