Search in sources :

Example 1 with Pair

use of com.ms.silverking.collection.Pair in project SilverKing by Morgan-Stanley.

the class DirectoryInMemorySS method serializeDir.

/*
	public DirectoryInMemorySS(byte[] buf, int offset, int limit, SSStorageParameters storageParams) {
		super(buf, offset, limit);
		this.storageParams = storageParams;
	}
	*/
public Pair<SSStorageParameters, byte[]> serializeDir() {
    byte[] serializedDir;
    StorageParameters sp;
    byte[] checksum;
    serializedDir = serialize();
    checksum = new byte[0];
    sp = new StorageParameters(latestUpdateSP.getVersion(), serializedDir.length, serializedDir.length, CCSSUtil.createCCSS(Compression.NONE, ChecksumType.NONE), checksum, latestUpdateSP.getValueCreator(), latestUpdateSP.getCreationTime());
    return new Pair<>(sp, serializedDir);
}
Also used : StorageParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageParameters) SSStorageParameters(com.ms.silverking.cloud.dht.serverside.SSStorageParameters) Pair(com.ms.silverking.collection.Pair)

Example 2 with Pair

use of com.ms.silverking.collection.Pair in project SilverKing by Morgan-Stanley.

the class SystemNamespaceStore method getAllReplicasFreeSystemDiskBytesEstimate.

private byte[] getAllReplicasFreeSystemDiskBytesEstimate() {
    List<Pair<IPAndPort, Long>> results;
    Map<IPAndPort, NodeInfo> nodeInfo;
    results = new ArrayList<>();
    try {
        nodeInfo = getAllNodeInfo();
        for (IPAndPort node : ringMaster.getAllCurrentReplicaServers()) {
            NodeInfo info;
            info = nodeInfo.get(node);
            if (info != null) {
                long freeSystemBytesEstimate;
                freeSystemBytesEstimate = (long) ((double) info.getFSFreeBytes() / ringMaster.getCurrentOwnedFraction(node, OwnerQueryMode.Primary));
                results.add(new Pair<>(node, freeSystemBytesEstimate));
            }
        }
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
    }
    return pairedResultsToBytes(results);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) NodeInfo(com.ms.silverking.cloud.dht.daemon.NodeInfo) KeeperException(org.apache.zookeeper.KeeperException) Pair(com.ms.silverking.collection.Pair)

Example 3 with Pair

use of com.ms.silverking.collection.Pair in project SilverKing by Morgan-Stanley.

the class SystemNamespaceStore method getAllReplicasFreeDiskBytes.

private byte[] getAllReplicasFreeDiskBytes() {
    List<Pair<IPAndPort, Long>> results;
    Map<IPAndPort, NodeInfo> nodeInfo;
    results = new ArrayList<>();
    try {
        nodeInfo = getAllNodeInfo();
        for (IPAndPort node : ringMaster.getAllCurrentReplicaServers()) {
            NodeInfo info;
            info = nodeInfo.get(node);
            if (info != null) {
                results.add(new Pair<>(node, info.getFSFreeBytes()));
            }
        }
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
    }
    return pairedResultsToBytes(results);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) NodeInfo(com.ms.silverking.cloud.dht.daemon.NodeInfo) KeeperException(org.apache.zookeeper.KeeperException) Pair(com.ms.silverking.collection.Pair)

Example 4 with Pair

use of com.ms.silverking.collection.Pair in project SilverKing by Morgan-Stanley.

the class SKAdmin method _getActiveDaemons.

private Pair<Boolean, Set<IPAndPort>> _getActiveDaemons() {
    try {
        Set<IPAndPort> activeDaemons;
        activeDaemons = suspectsZK.readActiveNodesFromZK();
        for (IPAndPort daemon : activeDaemons) {
            System.out.printf("%s\n", daemon.getIPAsString());
        }
        return new Pair<>(true, activeDaemons);
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
        return new Pair(false, ImmutableSet.of());
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) KeeperException(org.apache.zookeeper.KeeperException) Pair(com.ms.silverking.collection.Pair)

Example 5 with Pair

use of com.ms.silverking.collection.Pair in project SilverKing by Morgan-Stanley.

the class SKAdmin method getRing.

private static Pair<RingConfiguration, InstantiatedRingTree> getRing(DHTConfiguration dhtConfig, com.ms.silverking.cloud.dht.meta.MetaClient dhtMC) throws IOException, KeeperException {
    String ringName;
    Pair<Long, Long> ringVersion;
    DHTRingCurTargetZK dhtRingCurTargetZK;
    Triple<String, Long, Long> curRingNameAndVersion;
    RingConfiguration ringConfig;
    RingConfigurationZK ringConfigZK;
    InstantiatedRingTree ringTree;
    com.ms.silverking.cloud.toporing.meta.MetaClient ringMC;
    dhtRingCurTargetZK = new DHTRingCurTargetZK(dhtMC, dhtConfig);
    curRingNameAndVersion = dhtRingCurTargetZK.getCurRingAndVersionPair();
    if (curRingNameAndVersion == null) {
        return null;
    }
    ringName = curRingNameAndVersion.getHead();
    ringVersion = curRingNameAndVersion.getTail();
    ringMC = com.ms.silverking.cloud.toporing.meta.MetaClient.createMetaClient(ringName, ringVersion.getV1(), dhtMC.getZooKeeper().getZKConfig());
    ringConfigZK = new RingConfigurationZK(ringMC);
    ringConfig = ringConfigZK.readFromZK(ringVersion.getV1(), null);
    // ringTree = SingleRingZK.readTree(ringMC, ringVersion);
    // FUTURE - think about whether or not we should keep this, currently unused
    ringTree = null;
    return new Pair<>(ringConfig, ringTree);
}
Also used : RingConfigurationZK(com.ms.silverking.cloud.toporing.meta.RingConfigurationZK) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree) DHTRingCurTargetZK(com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK) RingConfiguration(com.ms.silverking.cloud.toporing.meta.RingConfiguration) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration) Pair(com.ms.silverking.collection.Pair)

Aggregations

Pair (com.ms.silverking.collection.Pair)16 IPAndPort (com.ms.silverking.net.IPAndPort)6 KeeperException (org.apache.zookeeper.KeeperException)3 DaemonState (com.ms.silverking.cloud.dht.daemon.DaemonState)2 NodeInfo (com.ms.silverking.cloud.dht.daemon.NodeInfo)2 DHTRingCurTargetZK (com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK)2 SSStorageParameters (com.ms.silverking.cloud.dht.serverside.SSStorageParameters)2 ImmutableList (com.google.common.collect.ImmutableList)1 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)1 OperationState (com.ms.silverking.cloud.dht.client.OperationState)1 StorageParameters (com.ms.silverking.cloud.dht.daemon.storage.StorageParameters)1 DaemonStateZK (com.ms.silverking.cloud.dht.meta.DaemonStateZK)1 PutTrigger (com.ms.silverking.cloud.dht.serverside.PutTrigger)1 RetrieveTrigger (com.ms.silverking.cloud.dht.serverside.RetrieveTrigger)1 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)1 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)1 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)1 RingConfigurationZK (com.ms.silverking.cloud.toporing.meta.RingConfigurationZK)1 Quadruple (com.ms.silverking.collection.Quadruple)1 UUIDBase (com.ms.silverking.id.UUIDBase)1