Skip to content

Instantly share code, notes, and snippets.

@iliapolo
Created May 2, 2015 13:01
Show Gist options
  • Save iliapolo/1a74b383bf5a40d15430 to your computer and use it in GitHub Desktop.
Save iliapolo/1a74b383bf5a40d15430 to your computer and use it in GitHub Desktop.
Scaling example of an ElasticSpace (Elastic Service Manager - Gigaspaces)
private void scaleByMemory() {
Admin admin = new AdminFactory().addGroup("elip-xap").createAdmin();
// discover the space
space = admin.getProcessingUnits().waitFor("mySpace");
// scale to 128MB of memery capacity. this means that number of container will be 128/memeoryCapacityPerContainer
space.scale(new ManualCapacityScaleConfigurer().memoryCapacity(128, MemoryUnit.MEGABYTES).create());
}
private void scaleByCpu() {
Admin admin = new AdminFactory().addGroup("elip-xap").createAdmin();
// discover the space
space = admin.getProcessingUnits().waitFor("mySpace");
// scale so that the processing unit will use 8 cpu cores in total. so if each machine has 2 cores the pu will
// have to spread to at least 4 machines
space.scale(new ManualCapacityScaleConfigurer().numberOfCpuCores(6).create());
}
private void scaleByEager() {
Admin admin = new AdminFactory().addGroup("elip-xap").createAdmin();
// discover the space
space = admin.getProcessingUnits().waitFor("mySpace");
// scale to utilize the maximum number of cpu's and start as many containers as possible
// to reach maximum memory utilization
space.scale(new new EagerScaleConfig());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment