Pivotal Knowledge Base


Assigning buckets in run-time using a function

Applies To



Describe how buckets can be assigned in run-time after servers are started up.


There is no gfsh command to assign buckets. The "start server" command has the option --assign-bucket at start time but that doesn't help if you want to assign buckets after start-up.

A solution is to use a function and run that on the server or servers where buckets should be assigned.

The following function takes a list of region names to assign buckets to. Use the Execution methods to choose where to run:

public class AssignBucketsFunction implements Function, Declarable {
public void execute(FunctionContext context) {
Set<String> regionNames = (Set<String>) context.getArguments();
System.out.println(Thread.currentThread().getName() + ": Function " + getId() + ": Assigning buckets for " + regionNames);
Cache cache = CacheFactory.getAnyInstance();
for (String regionName : regionNames) {
Region region = cache.getRegion(regionName);

public String getId() {
return getClass().getSimpleName();
public boolean optimizeForWrite() {
return true;
public boolean hasResult() {
return true;
public boolean isHA() {
return true;
public void init(Properties properties) {


Powered by Zendesk