Skip to content

Commit

Permalink
dcache-chimera: add get AccessLatency and ger RetentionPolicy comman…
Browse files Browse the repository at this point in the history
…d to CLI

    Modification:

    org.dcache.chimera.cli has been moved to dcache-chimera.

    Result:

    Users can query AccessLatency and  RetentionPolicy for a file/directory

    Target: master
    Requires-notes: yes
    Requires-book: yes
    Request: 3.0
    Patch:
  • Loading branch information
mksahakyan committed Dec 14, 2016
1 parent d9ec1e5 commit db0a2b1
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
Expand All @@ -35,6 +36,10 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import diskCacheV111.util.AccessLatency;
import diskCacheV111.util.CacheException;
import diskCacheV111.util.RetentionPolicy;

import dmg.util.command.Argument;
import dmg.util.command.Command;
import dmg.util.command.Option;
Expand All @@ -52,6 +57,9 @@
import org.dcache.chimera.HimeraDirectoryEntry;
import org.dcache.chimera.NotDirChimeraException;
import org.dcache.chimera.UnixPermission;
import org.dcache.chimera.namespace.ChimeraOsmStorageInfoExtractor;
import org.dcache.chimera.namespace.ChimeraStorageInfoExtractable;
import org.dcache.chimera.namespace.ExtendedInode;
import org.dcache.chimera.posix.Stat;
import org.dcache.util.Args;
import org.dcache.util.Checksum;
Expand All @@ -68,28 +76,43 @@
public class Shell extends ShellApplication
{
private final FileSystemProvider fs;
private final ChimeraStorageInfoExtractable extractor;

private String path = "/";
private FsInode pwd;

public static void main(String[] arguments) throws Throwable
{
if (arguments.length < 3) {
System.err.println("Usage: chimera <jdbcUrl> <dbUser> <dbPass>");



public static void main(String[] arguments) throws Throwable {
if (arguments.length < 6) {
System.err.println("Usage: chimera <jdbcUrl> <dbUser> <dbPass> " +
"<storageInfoExtractor> <accessLatency> <retentionPolicy>");
System.exit(4);
}

Args args = new Args(arguments);
args.shift(3);
args.shift(6);

try (Shell shell = new Shell(arguments[0], arguments[1], arguments[2])) {
try (Shell shell = new Shell(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5])) {
shell.start(args);
}
}

public Shell(String url, String user, String password) throws Exception
public Shell(String url, String user, String password, String extractor, String accessLatency, String retentionPolicy) throws Exception
{

fs = FsFactory.createFileSystem(url, user, password);
pwd = fs.path2inode(path);


Class<? extends ChimeraOsmStorageInfoExtractor> storageInfoExtractor =
Class.forName(extractor).asSubclass(ChimeraOsmStorageInfoExtractor.class);
Constructor<? extends ChimeraStorageInfoExtractable> constructor = storageInfoExtractor.getConstructor(AccessLatency.class, RetentionPolicy.class);

this.extractor = (ChimeraStorageInfoExtractable) constructor.newInstance(
AccessLatency.getAccessLatency(accessLatency),
RetentionPolicy.getRetentionPolicy(retentionPolicy));
}

@Override
Expand Down Expand Up @@ -595,9 +618,10 @@ public class ReadTagCommand implements Callable<Serializable>
String tag;

@Override
public Serializable call() throws IOException
public Serializable call() throws IOException, CacheException
{
FsInode inode = lookup(path);

Stat stat = fs.statTag(inode, tag);
byte[] data = new byte[(int) stat.getSize()];
fs.getTag(inode, tag, data, 0, data.length);
Expand All @@ -606,6 +630,44 @@ public Serializable call() throws IOException
}
}

@Command(name = "get AccessLatency", hint = "display access latency of files/directories")
public class GetAccessLatencyCommand implements Callable<Serializable>
{
@Argument(required = false)
File path;

@Override
public Serializable call() throws IOException, CacheException
{

ExtendedInode inode = new ExtendedInode(fs, lookup(path));
AccessLatency accessLatency = extractor.getAccessLatency(inode);

console.println(accessLatency.toString());
return null;
}
}


@Command(name = "get RetentionPolicy", hint = "display retention policy of files/directories")
public class GetRetentionPolicyCommand implements Callable<Serializable>
{

@Argument(required = false)
File path;

@Override
public Serializable call() throws IOException, CacheException
{

ExtendedInode inode = new ExtendedInode(fs, lookup(path));
RetentionPolicy retentionPolicy = extractor.getRetentionPolicy(inode);

console.println(retentionPolicy.toString());
return null;
}
}

@Command(name = "writetag", hint = "write tag data")
public class WriteTagCommand implements Callable<Serializable>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ dcache.authn.capath.refresh.unit=SECONDS

dcache.description = system-test (built from ${dcache.scm-state})

dcache.default-access-latency=ONLINE
dcache.default-retention-policy=REPLICA


hsqldb.path=${system-test.home}/var/db

pool.plugins.meta=org.dcache.pool.repository.meta.db.BerkeleyDBMetaDataRepository
Expand All @@ -44,8 +48,6 @@ admin.paths.history=${system-test.home}/var/admin/history

[dCacheDomain/topo]
[dCacheDomain/pnfsmanager]
pnfsmanager.default-retention-policy=REPLICA
pnfsmanager.default-access-latency=ONLINE
pnfsmanager.limits.list-chunk-size=5
pnfsmanager.enable.acl=true

Expand Down
2 changes: 2 additions & 0 deletions plugins/hsqldb/src/main/skel/hsqldb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ billing.db.schema.changelog=${billing.db.hsql.schema.changelog-when-${billing.en

chimera.db.url = jdbc:hsqldb:file:${hsqldb.path}/${chimera.db.name};shutdown=true;hsqldb.tx=mvcc;hsqldb.sqllog=3

chimerashell.db.url = jdbc:hsqldb:file:${hsqldb.path}/${chimerashell.db.name};shutdown=true;hsqldb.tx=mvcc;hsqldb.sqllog=3

pinmanager.db.url = jdbc:hsqldb:file:${hsqldb.path}/${pinmanager.db.name};shutdown=true;hsqldb.tx=mvcc;hsqldb.sqllog=3

replica.db.url = jdbc:hsqldb:file:${hsqldb.path}/${replica.db.name};shutdown=true;hsqldb.tx=mvcc;hsqldb.sqllog=3
Expand Down
11 changes: 7 additions & 4 deletions skel/bin/chimera
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
lib="$(getProperty dcache.paths.share.lib)"
. ${lib}/utils.sh

classpath=$(printLimitedClassPath chimera HikariCP javassist \
classpath=$(printLimitedClassPath dcache-vehicles dcache-chimera chimera HikariCP javassist \
guava jline common-cli dcache-common acl-vehicles acl \
slf4j-api logback-classic logback-core logback-console-config jcl-over-slf4j \
spring-core spring-beans spring-jdbc spring-tx \
postgresql h2 hsqldb)

CLASSPATH="$classpath" quickJava -Dlog=${DCACHE_LOG:-warn} \
org.dcache.chimera.cli.Shell \
"$(getProperty chimera.db.url)" \
"$(getProperty chimera.db.user)" \
"$(getProperty chimera.db.password)" \
"$(getProperty chimerashell.db.url)" \
"$(getProperty chimerashell.db.user)" \
"$(getProperty chimerashell.db.password)" \
"$(getProperty chimerashell.plugins.storage-info-extractor)" \
"$(getProperty chimerashell.default-access-latency)" \
"$(getProperty chimerashell.default-retention-policy)" \
"$@"

38 changes: 38 additions & 0 deletions skel/share/defaults/chimerashell.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -----------------------------------------------------------------------
# Default values for Chimera namespace DB configuration
# as well as for Access Latency and Retention Policy used in CLI Shell.
# -----------------------------------------------------------------------
@DEFAULTS_HEADER@

# ---- Chimera database name
#
chimerashell.db.name = chimera

# ---- Chimera database host name
#
# See dcache.db.host for details.
#
chimerashell.db.host = ${dcache.db.host}

# ---- URL of db connection
chimerashell.db.url = jdbc:postgresql://${chimerashell.db.name}/${chimerashell.db.host }?prepareThreshold=3&targetServerType=master
# ---- Database user name
#
chimerashell.db.user = ${dcache.db.user}

# ---- Database user password
#
chimerashell.db.password = ${dcache.db.password}

# ---- Database password file
#
chimerashell.db.password.file = ${dcache.db.password.file}

chimerashell.db.schema.changelog = org/dcache/chimera/changelog/changelog-master.xml

# Default Access Latency and Retention Policy

chimerashell.plugins.storage-info-extractor = ${dcache.plugins.storage-info-extractor}

(one-of?ONLINE|NEARLINE|${dcache.default-access-latency})chimerashell.default-access-latency = ${dcache.default-access-latency}
(one-of?CUSTODIAL|REPLICA|OUTPUT|${dcache.default-retention-policy})chimerashell.default-retention-policy = ${dcache.default-retention-policy}
9 changes: 9 additions & 0 deletions skel/share/defaults/dcache.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1036,3 +1036,12 @@ dcache.oidc.hostnames =
(obsolete)dcache.broker.host = See dcache.zookeeper.connection
(obsolete)dcache.broker.domain = See dcache.broker.scheme
(obsolete)dcache.service.billing = See dcache.queue.billing and dcache.topic.billing


# -----------------------------------------------------------------------
# ---- Default Access Latency and Retention Policy
# -----------------------------------------------------------------------

(one-of?ONLINE|NEARLINE)dcache.default-access-latency=NEARLINE
(one-of?CUSTODIAL|REPLICA|OUTPUT)dcache.default-retention-policy=CUSTODIAL
dcache.plugins.storage-info-extractor = org.dcache.chimera.namespace.ChimeraOsmStorageInfoExtractor
7 changes: 4 additions & 3 deletions skel/share/defaults/pnfsmanager.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pnfsmanager.cell.subscribe = ${dcache.topic.watched}
# -- replace with org.dcache.chimera.namespace.ChimeraEnstoreStorageInfoExtractor
# if you are running an enstore HSM backend.
#
pnfsmanager.plugins.storage-info-extractor = org.dcache.chimera.namespace.ChimeraOsmStorageInfoExtractor
pnfsmanager.plugins.storage-info-extractor=${dcache.plugins.storage-info-extractor}

# ---- Number of threads per thread group
#
Expand Down Expand Up @@ -212,9 +212,10 @@ pnfsmanager.service.spacemanager = ${dcache.service.spacemanager}
#
# Do not use OUTPUT.
#
(one-of?CUSTODIAL|REPLICA|OUTPUT)pnfsmanager.default-retention-policy = CUSTODIAL

(one-of?ONLINE|NEARLINE)pnfsmanager.default-access-latency = NEARLINE
(one-of?ONLINE|NEARLINE|${dcache.default-access-latency})pnfsmanager.default-access-latency=${dcache.default-access-latency}

(one-of?CUSTODIAL|REPLICA|OUTPUT|${dcache.default-retention-policy})pnfsmanager.default-retention-policy=${dcache.default-retention-policy}

# ---- Upload directory
#
Expand Down

0 comments on commit db0a2b1

Please sign in to comment.