Skip to content

Commit 659135e

Browse files
authored
Add getFileChecksum and getPathsByFileId (#116)
1 parent 21a5fb5 commit 659135e

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

  • common/src/main/java/org/commonjava/storage/pathmapped/spi
  • pathdb
  • storage/src/main/java/org/commonjava/storage/pathmapped/metrics

common/src/main/java/org/commonjava/storage/pathmapped/spi/PathDB.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.commonjava.storage.pathmapped.spi;
1717

18+
import org.commonjava.storage.pathmapped.model.FileChecksum;
1819
import org.commonjava.storage.pathmapped.model.PathMap;
1920
import org.commonjava.storage.pathmapped.model.Reclaim;
2021

@@ -26,6 +27,10 @@
2627

2728
public interface PathDB
2829
{
30+
FileChecksum getFileChecksum( String checksum );
31+
32+
Set<String> getPathsByFileId( String fileId );
33+
2934
enum FileType {
3035
all, file, dir;
3136
};

pathdb/datastax/src/main/java/org/commonjava/storage/pathmapped/pathdb/datastax/CassandraPathDB.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,4 +934,21 @@ public void purgeFilesystem( Filesystem filesystem )
934934
filesystemMapper.delete( filesystem.getFilesystem() );
935935
}
936936
}
937+
938+
@Override
939+
public FileChecksum getFileChecksum( String checksum )
940+
{
941+
return fileChecksumMapper.get( checksum );
942+
}
943+
944+
@Override
945+
public Set<String> getPathsByFileId( String fileId )
946+
{
947+
ReverseMap reverseMap = reverseMapMapper.get( fileId );
948+
if ( reverseMap != null )
949+
{
950+
return reverseMap.getPaths();
951+
}
952+
return emptySet();
953+
}
937954
}

pathdb/jpa/src/main/java/org/commonjava/storage/pathmapped/pathdb/jpa/JPAPathDB.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.commonjava.storage.pathmapped.pathdb.jpa;
1717

18+
import org.commonjava.storage.pathmapped.model.FileChecksum;
1819
import org.commonjava.storage.pathmapped.pathdb.jpa.model.JpaPathKey;
1920
import org.commonjava.storage.pathmapped.pathdb.jpa.model.JpaPathMap;
2021
import org.commonjava.storage.pathmapped.pathdb.jpa.model.JpaReclaim;
@@ -56,6 +57,18 @@ public JPAPathDB( String persistenceUnitName )
5657
entitymanager = factory.createEntityManager();
5758
}
5859

60+
@Override
61+
public FileChecksum getFileChecksum( String checksum )
62+
{
63+
return null;
64+
}
65+
66+
@Override
67+
public Set<String> getPathsByFileId( String fileId )
68+
{
69+
return null;
70+
}
71+
5972
public List<PathMap> list( String fileSystem, String path, FileType fileType )
6073
{
6174
if ( path.endsWith( "/" ) )

storage/src/main/java/org/commonjava/storage/pathmapped/metrics/MeasuredPathDB.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.commonjava.storage.pathmapped.metrics;
1717

1818
import org.commonjava.o11yphant.metrics.MetricsManager;
19+
import org.commonjava.storage.pathmapped.model.FileChecksum;
1920
import org.commonjava.storage.pathmapped.model.PathMap;
2021
import org.commonjava.storage.pathmapped.model.Reclaim;
2122
import org.commonjava.storage.pathmapped.spi.PathDB;
@@ -45,6 +46,18 @@ public MeasuredPathDB( PathDB decorated, MetricsManager metricsManager, String m
4546
this.metricPrefix = metricPrefix;
4647
}
4748

49+
@Override
50+
public FileChecksum getFileChecksum( String checksum )
51+
{
52+
return measure( () -> decorated.getFileChecksum( checksum ), "getFileChecksum" );
53+
}
54+
55+
@Override
56+
public Set<String> getPathsByFileId( String fileId )
57+
{
58+
return measure( () -> decorated.getPathsByFileId( fileId ), "getPathsByFileId" );
59+
}
60+
4861
@Override
4962
public List<PathMap> list( String fileSystem, String path, FileType fileType )
5063
{

0 commit comments

Comments
 (0)