Skip to content

Commit

Permalink
Add getFileChecksum and getPathsByFileId (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhan1 authored Sep 19, 2024
1 parent 21a5fb5 commit 659135e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.commonjava.storage.pathmapped.spi;

import org.commonjava.storage.pathmapped.model.FileChecksum;
import org.commonjava.storage.pathmapped.model.PathMap;
import org.commonjava.storage.pathmapped.model.Reclaim;

Expand All @@ -26,6 +27,10 @@

public interface PathDB
{
FileChecksum getFileChecksum( String checksum );

Set<String> getPathsByFileId( String fileId );

enum FileType {
all, file, dir;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,4 +934,21 @@ public void purgeFilesystem( Filesystem filesystem )
filesystemMapper.delete( filesystem.getFilesystem() );
}
}

@Override
public FileChecksum getFileChecksum( String checksum )
{
return fileChecksumMapper.get( checksum );
}

@Override
public Set<String> getPathsByFileId( String fileId )
{
ReverseMap reverseMap = reverseMapMapper.get( fileId );
if ( reverseMap != null )
{
return reverseMap.getPaths();
}
return emptySet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.commonjava.storage.pathmapped.pathdb.jpa;

import org.commonjava.storage.pathmapped.model.FileChecksum;
import org.commonjava.storage.pathmapped.pathdb.jpa.model.JpaPathKey;
import org.commonjava.storage.pathmapped.pathdb.jpa.model.JpaPathMap;
import org.commonjava.storage.pathmapped.pathdb.jpa.model.JpaReclaim;
Expand Down Expand Up @@ -56,6 +57,18 @@ public JPAPathDB( String persistenceUnitName )
entitymanager = factory.createEntityManager();
}

@Override
public FileChecksum getFileChecksum( String checksum )
{
return null;
}

@Override
public Set<String> getPathsByFileId( String fileId )
{
return null;
}

public List<PathMap> list( String fileSystem, String path, FileType fileType )
{
if ( path.endsWith( "/" ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.commonjava.storage.pathmapped.metrics;

import org.commonjava.o11yphant.metrics.MetricsManager;
import org.commonjava.storage.pathmapped.model.FileChecksum;
import org.commonjava.storage.pathmapped.model.PathMap;
import org.commonjava.storage.pathmapped.model.Reclaim;
import org.commonjava.storage.pathmapped.spi.PathDB;
Expand Down Expand Up @@ -45,6 +46,18 @@ public MeasuredPathDB( PathDB decorated, MetricsManager metricsManager, String m
this.metricPrefix = metricPrefix;
}

@Override
public FileChecksum getFileChecksum( String checksum )
{
return measure( () -> decorated.getFileChecksum( checksum ), "getFileChecksum" );
}

@Override
public Set<String> getPathsByFileId( String fileId )
{
return measure( () -> decorated.getPathsByFileId( fileId ), "getPathsByFileId" );
}

@Override
public List<PathMap> list( String fileSystem, String path, FileType fileType )
{
Expand Down

0 comments on commit 659135e

Please sign in to comment.