Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Get only primary partitions from admin API

Hi,

How can i get the list of all primary partitions only with admin api. I have 20 partitions and 20 backups i am using the below code get partitions list

     Map<String, Integer> gscList = new HashMap<String, Integer>();

    ProcessingUnit gcmmSpacePu = admin.getProcessingUnits().waitFor("gcmm-space-pu");
    ProcessingUnitInstance[] pxs = gcmmSpacePu.getInstances();
    for (ProcessingUnitInstance processingUnitInstance : gcmmSpacePu.getInstances()) {
        gscList.put(processingUnitInstance.getGridServiceContainer().getUid(), processingUnitInstance.getClusterInfo().getInstanceId());
    }

I want my map to contain only primary instances not backup

asked 2016-09-14 11:48:26 -0600

Harvey gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Harvey

I guess you mean this

         ProcessingUnits units = admin.getProcessingUnits();
         for (ProcessingUnit unit : units) {
             System.out.println(unit.getName());
             for (ProcessingUnitPartition partition: unit.getPartitions()) {
                ProcessingUnitInstance primary = partition.getPrimary();
                ProcessingUnitInstance backup = partition.getBackup();
                System.out.println(partition.getPartitionId() + " : " + primary.getInstanceId() + "_" + primary.getBackupId());
                System.out.println(partition.getPartitionId() + " : " + backup.getInstanceId() + "_" + backup.getBackupId());
             }
         }

Regards

John

answered 2016-09-14 12:16:05 -0600

jb gravatar image
edit flag offensive delete link more

Comments

ProcessingUnitInstance primary = partition.getPrimary(); -> this always gives me null, any idea why ?

Harvey gravatar imageHarvey ( 2016-09-14 12:43:17 -0600 )edit

I had to resort something like this

for (ProcessingUnitPartition processingUnitPartition : gcmmSpacePu.getPartitions()) {
        ProcessingUnitInstance primary = processingUnitPartition.getPrimary();
        for (ProcessingUnitInstance processingUnitInstance : processingUnitPartition.getInstances()) {
            if (processingUnitInstance.getClusterInfo().getInstanceId() != null && processingUnitInstance.getClusterInfo().getBackupId() == null) {
                stringSet.put(processingUnitInstance.getGridServiceContainer().getUid(), processingUnitInstance.getClusterInfo().getInstanceId());
            }
        }
    }
Harvey gravatar imageHarvey ( 2016-09-14 12:46:42 -0600 )edit

For a 2,1 partitioned-sync2backup I get the following:

space 0 : 1_0 0 : 1_1 1 : 2_0 1 : 2_1

jb gravatar imagejb ( 2016-09-14 13:01:50 -0600 )edit

what are you running this against, IPUC, Standalone, or actual deployment?

jb gravatar imagejb ( 2016-09-15 08:45:30 -0600 )edit

i am running this againg actual deployment, which has all components started like, lus, gsa, gsc, gsm, pus, zones

Harvey gravatar imageHarvey ( 2016-09-15 08:52:06 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-14 11:48:26 -0600

Seen: 1,245 times

Last updated: Sep 14 '16