Search in sources :

Example 1 with NamespaceOptions

use of com.ms.silverking.cloud.dht.NamespaceOptions in project SilverKing by Morgan-Stanley.

the class SilverKingClient method doCreateNamespace.

private void doCreateNamespace(String[] args) throws OperationException, IOException {
    String name;
    NamespaceOptions nsOptions;
    name = args[0];
    if (args.length > 1) {
        nsOptions = NamespaceOptions.parse(args[1]);
    } else {
        nsOptions = null;
    }
    opMessage("Creating namespace");
    if (verbose) {
        System.out.printf("NamespaceOptions: %s\n", nsOptions);
    }
    sw.reset();
    session.createNamespace(name, nsOptions);
    sw.stop();
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions)

Example 2 with NamespaceOptions

use of com.ms.silverking.cloud.dht.NamespaceOptions in project SilverKing by Morgan-Stanley.

the class SilverKingClient method doLinkToNamespace.

private void doLinkToNamespace(String[] args) throws OperationException, IOException {
    String parent;
    NamespaceOptions nsOptions;
    nsOptions = syncNSP.getNamespace().getOptions();
    switch(nsOptions.getVersionMode()) {
        case SINGLE_VERSION:
            break;
        default:
            System.out.println("linkToNamespace is only supported for NamespaceVersionMode.SINGLE_VERSION");
            return;
    }
    parent = args[0];
    opMessage("Linking namespace");
    sw.reset();
    syncNSP.getNamespace().linkTo(parent);
    sw.stop();
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions)

Example 3 with NamespaceOptions

use of com.ms.silverking.cloud.dht.NamespaceOptions in project SilverKing by Morgan-Stanley.

the class ClientTool method doCreateNamespace.

private void doCreateNamespace(ClientOptions options, DHTSession session, Stopwatch sw) throws OperationException, IOException {
    long version;
    NamespaceOptions nsOptions;
    if (options.nsOptions != null) {
        nsOptions = NamespaceOptions.parse(options.nsOptions);
    } else {
        nsOptions = null;
    }
    if (options.version > 0) {
        version = options.version;
    } else {
        version = DHTUtil.currentTimeMillis();
    }
    Log.warning("Creating syncRequest");
    sw.reset();
    for (int i = 0; i < options.reps; i++) {
        session.createNamespace(options.namespace, nsOptions);
    }
    sw.stop();
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 4 with NamespaceOptions

use of com.ms.silverking.cloud.dht.NamespaceOptions in project SilverKing by Morgan-Stanley.

the class SegmentDebug method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        if (args.length != 2) {
            System.out.println("args: <nsDir> <segmentNumber>");
        } else {
            File nsDir;
            int segmentNumber;
            NamespaceOptions nsOptions;
            nsDir = new File(args[0]);
            if (!nsDir.isDirectory()) {
                throw new RuntimeException("Can't find nsDir: " + nsDir);
            }
            segmentNumber = Integer.parseInt(args[1]);
            nsOptions = NamespacePropertiesIO.read(nsDir).getOptions();
            System.out.println(nsOptions);
            new SegmentDebug(nsDir).debug(segmentNumber, nsOptions);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) File(java.io.File) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint) IOException(java.io.IOException)

Example 5 with NamespaceOptions

use of com.ms.silverking.cloud.dht.NamespaceOptions in project SilverKing by Morgan-Stanley.

the class FileSegmentRecoverer method readFullSegment.

void readFullSegment(int segmentNumber, SegmentIndexLocation segmentIndexLocation, SegmentPrereadMode segmentPrereadMode) {
    Stopwatch sw;
    Log.warning("Reading full segment: ", segmentNumber);
    sw = new SimpleStopwatch();
    try {
        FileSegment segment;
        NamespaceProperties nsProperties;
        NamespaceOptions nsOptions;
        // DataSegmentWalker       dsWalker;
        nsProperties = NamespacePropertiesIO.read(nsDir);
        nsOptions = nsProperties.getOptions();
        segment = FileSegment.openReadOnly(nsDir, segmentNumber, nsOptions.getSegmentSize(), nsOptions, segmentIndexLocation, segmentPrereadMode);
        for (DHTKeyIntEntry entry : segment.getPKC()) {
            int offset;
            offset = entry.getValue();
            if (offset < 0) {
                OffsetList offsetList;
                offsetList = segment.offsetListStore.getOffsetList(-offset);
                for (int listOffset : offsetList) {
                    System.out.printf("%s\t%d\t%d\t%f\t*%d\t%d\n", entry, segment.getCreationTime(offset), segment.getVersion(listOffset), KeyUtil.keyEntropy(entry), offset, offsetList);
                // nsStore.putSegmentNumberAndVersion(entry.getKey(), segmentNumber, segment.getVersion(listOffset));
                }
            } else {
                System.out.printf("%s\t%d\t%d\t%f\t%d\n", entry, segment.getCreationTime(offset), segment.getVersion(offset), KeyUtil.keyEntropy(entry), offset);
            // nsStore.putSegmentNumberAndVersion(entry.getKey(), segmentNumber, segment.getVersion(offset));
            }
        }
        // dsWalker = new DataSegmentWalker(segment.dataBuf);
        // for (DataSegmentWalkEntry entry : dsWalker) {
        // nsStore.addToSizeStats(entry.getUncompressedLength(), entry.getCompressedLength());
        // }
        segment.close();
        sw.stop();
        Log.warning("Done reading full segment: ", segmentNumber + " " + sw);
    } catch (IOException ioe) {
        Log.logErrorWarning(ioe, "Unable to recover: " + segmentNumber);
    }
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) NamespaceProperties(com.ms.silverking.cloud.dht.common.NamespaceProperties) DHTKeyIntEntry(com.ms.silverking.cloud.dht.collection.DHTKeyIntEntry) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) IOException(java.io.IOException) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Aggregations

NamespaceOptions (com.ms.silverking.cloud.dht.NamespaceOptions)24 NamespaceProperties (com.ms.silverking.cloud.dht.common.NamespaceProperties)8 IOException (java.io.IOException)7 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)4 File (java.io.File)4 NamespaceNotCreatedException (com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)3 ByteBuffer (java.nio.ByteBuffer)2 NamespaceServerSideCode (com.ms.silverking.cloud.dht.NamespaceServerSideCode)1 SecondaryTarget (com.ms.silverking.cloud.dht.SecondaryTarget)1 TimeAndVersionRetentionPolicy (com.ms.silverking.cloud.dht.TimeAndVersionRetentionPolicy)1 ValueRetentionPolicy (com.ms.silverking.cloud.dht.ValueRetentionPolicy)1 DHTKeyIntEntry (com.ms.silverking.cloud.dht.collection.DHTKeyIntEntry)1 Context (com.ms.silverking.cloud.dht.common.Context)1 DataSegmentWalkEntry (com.ms.silverking.cloud.dht.daemon.storage.DataSegmentWalkEntry)1 DataSegmentWalker (com.ms.silverking.cloud.dht.daemon.storage.DataSegmentWalker)1 SimpleStopwatch (com.ms.silverking.time.SimpleStopwatch)1 Stopwatch (com.ms.silverking.time.Stopwatch)1 FileNotFoundException (java.io.FileNotFoundException)1 Date (java.util.Date)1 Test (org.junit.Test)1