cfg.setGridName("g" + i);
GridCacheConfiguration cacheCfg = cfg.getCacheConfiguration()[0];
GridCacheDistributionMode distro = i == 0 &&
args.distribution() == CLIENT_ONLY ? CLIENT_ONLY : PARTITIONED_ONLY;
cacheCfg.setCacheMode(args.cache());
cacheCfg.setDistributionMode(distro);
cacheCfg.setWriteSynchronizationMode(args.synchronization());