RpcCallback<AddServerCacheResponse> done) {
ImmutableBytesPtr tenantId = null;
if (request.hasTenantId()) {
tenantId = new ImmutableBytesPtr(request.getTenantId().toByteArray());
}
TenantCache tenantCache = GlobalCache.getTenantCache(this.env, tenantId);
ImmutableBytesWritable cachePtr =
org.apache.phoenix.protobuf.ProtobufUtil
.toImmutableBytesWritable(request.getCachePtr());
try {
@SuppressWarnings("unchecked")
Class<ServerCacheFactory> serverCacheFactoryClass =
(Class<ServerCacheFactory>) Class.forName(request.getCacheFactory().getClassName());
ServerCacheFactory cacheFactory = serverCacheFactoryClass.newInstance();
tenantCache.addServerCache(new ImmutableBytesPtr(request.getCacheId().toByteArray()),
cachePtr, cacheFactory);
} catch (Throwable e) {
ProtobufUtil.setControllerException(controller, new IOException(e));
}
AddServerCacheResponse.Builder responseBuilder = AddServerCacheResponse.newBuilder();