@Override
protected void doStart() {
try {
log.load();
RaftServiceEndpoint endpoint = new RaftServiceEndpoint(ctx);
Service replicaService = RaftProto.RaftService.newReflectiveService(endpoint);
rpcServer.registerService(replicaService);
rpcServer.startAsync().addListener(new Listener() {
@Override
public void running() {
ctx.setState(RaftStateContext.StateType.FOLLOWER);
}
}, MoreExecutors.sameThreadExecutor());
rpcServer.awaitRunning();
notifyStarted();
} catch (Exception e) {
notifyFailed(e);
}
}
java类com.google.protobuf.Service的实例源码
RaftService.java 文件源码
项目:TakinRPC
阅读 28
收藏 0
点赞 0
评论 0
HMaster.java 文件源码
项目:ditb
阅读 31
收藏 0
点赞 0
评论 0
@Override
public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service "+serviceDesc.getFullName()+
" already registered, rejecting request from "+instance
);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered master coprocessor service: service="+serviceDesc.getFullName());
}
return true;
}
HRegionServer.java 文件源码
项目:ditb
阅读 28
收藏 0
点赞 0
评论 0
@Override public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service " + serviceDesc.getFullName()
+ " already registered, rejecting request from " + instance);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug(
"Registered regionserver coprocessor service: service=" + serviceDesc.getFullName());
}
return true;
}
HRegion.java 文件源码
项目:ditb
阅读 27
收藏 0
点赞 0
评论 0
@Override public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service " + serviceDesc.getFullName()
+ " already registered, rejecting request from " + instance);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered coprocessor service: region=" + Bytes
.toStringBinary(getRegionInfo().getRegionName()) + " service=" + serviceDesc
.getFullName());
}
return true;
}
HTable.java 文件源码
项目:ditb
阅读 31
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
throws ServiceException, Throwable {
final Map<byte[],R> results = Collections.synchronizedMap(
new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
@Override
public void update(byte[] region, byte[] row, R value) {
if (region != null) {
results.put(region, value);
}
}
});
return results;
}
RpcForwarder.java 文件源码
项目:protobuf-socket-rpc
阅读 25
收藏 0
点赞 0
评论 0
/**
* Handle the blocking RPC request by forwarding it to the correct
* service/method.
*
* @throws RpcException If there was some error executing the RPC.
*/
public SocketRpcProtos.Response doBlockingRpc(
SocketRpcProtos.Request rpcRequest) throws RpcException {
// Get the service, first try BlockingService
BlockingService blockingService = blockingServiceMap.get(
rpcRequest.getServiceName());
if (blockingService != null) {
return forwardToBlockingService(rpcRequest, blockingService);
}
// Now try Service
Service service = serviceMap.get(rpcRequest.getServiceName());
if (service == null) {
throw new RpcException(ErrorReason.SERVICE_NOT_FOUND,
"Could not find service: " + rpcRequest.getServiceName(), null);
}
// Call service using an instant callback
Callback<Message> callback = new Callback<Message>();
SocketRpcController socketController = new SocketRpcController();
forwardToService(rpcRequest, callback, service, socketController);
// Build and return response (callback invocation is optional)
return createRpcResponse(callback.response, callback.invoked,
socketController);
}
RpcForwarder.java 文件源码
项目:protobuf-socket-rpc
阅读 25
收藏 0
点赞 0
评论 0
private void forwardToService(SocketRpcProtos.Request rpcRequest,
RpcCallback<Message> callback, Service service,
RpcController socketController) throws RpcException {
// Get matching method
MethodDescriptor method = getMethod(rpcRequest,
service.getDescriptorForType());
// Create request for method
Message request = getRequestProto(rpcRequest,
service.getRequestPrototype(method));
// Call method
try {
service.callMethod(method, socketController, request, callback);
} catch (RuntimeException e) {
throw new RpcException(ErrorReason.RPC_ERROR,
"Error running method " + method.getFullName(), e);
}
}
HMaster.java 文件源码
项目:pbase
阅读 28
收藏 0
点赞 0
评论 0
@Override
public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service " + serviceDesc.getFullName() +
" already registered, rejecting request from " + instance
);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered master coprocessor service: service=" + serviceDesc.getFullName());
}
return true;
}
HRegionServer.java 文件源码
项目:pbase
阅读 28
收藏 0
点赞 0
评论 0
@Override
public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service " + serviceDesc.getFullName()
+ " already registered, rejecting request from " + instance);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered regionserver coprocessor service: service=" + serviceDesc.getFullName());
}
return true;
}
HRegion.java 文件源码
项目:pbase
阅读 29
收藏 0
点赞 0
评论 0
/**
* Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to
* be available for handling
* {@link HRegion#execService(com.google.protobuf.RpcController,
* org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall)}} calls.
* <p/>
* <p>
* Only a single instance may be registered per region for a given {@link Service} subclass (the
* instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}.
* After the first registration, subsequent calls with the same service name will fail with
* a return value of {@code false}.
* </p>
*
* @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
* @return {@code true} if the registration was successful, {@code false}
* otherwise
*/
public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service " + serviceDesc.getFullName() +
" already registered, rejecting request from " + instance
);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered coprocessor service: region=" +
Bytes.toStringBinary(getRegionName()) + " service=" + serviceDesc.getFullName());
}
return true;
}
HTable.java 文件源码
项目:pbase
阅读 42
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
throws ServiceException, Throwable {
final Map<byte[],R> results = Collections.synchronizedMap(
new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
@Override
public void update(byte[] region, byte[] row, R value) {
if (region != null) {
results.put(region, value);
}
}
});
return results;
}
HMaster.java 文件源码
项目:HIndex
阅读 23
收藏 0
点赞 0
评论 0
@Override
public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service "+serviceDesc.getFullName()+
" already registered, rejecting request from "+instance
);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered master coprocessor service: service="+serviceDesc.getFullName());
}
return true;
}
HRegion.java 文件源码
项目:HIndex
阅读 30
收藏 0
点赞 0
评论 0
/**
* Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to
* be available for handling
* {@link HRegion#execService(com.google.protobuf.RpcController,
* org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall)}} calls.
*
* <p>
* Only a single instance may be registered per region for a given {@link Service} subclass (the
* instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}.
* After the first registration, subsequent calls with the same service name will fail with
* a return value of {@code false}.
* </p>
* @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
* @return {@code true} if the registration was successful, {@code false}
* otherwise
*/
public boolean registerService(Service instance) {
/*
* No stacking of instances is allowed for a single service name
*/
Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
LOG.error("Coprocessor service "+serviceDesc.getFullName()+
" already registered, rejecting request from "+instance
);
return false;
}
coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered coprocessor service: region="+
Bytes.toStringBinary(getRegionName())+" service="+serviceDesc.getFullName());
}
return true;
}
RegionCoprocessorHost.java 文件源码
项目:HIndex
阅读 28
收藏 0
点赞 0
评论 0
public Message preEndpointInvocation(final Service service, final String methodName,
Message request) throws IOException {
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
for (RegionEnvironment env : coprocessors) {
if (env.getInstance() instanceof EndpointObserver) {
ctx = ObserverContext.createAndPrepare(env, ctx);
Thread currentThread = Thread.currentThread();
ClassLoader cl = currentThread.getContextClassLoader();
try {
currentThread.setContextClassLoader(env.getClassLoader());
request = ((EndpointObserver) env.getInstance()).preEndpointInvocation(ctx, service,
methodName, request);
} catch (Throwable e) {
handleCoprocessorThrowable(env, e);
} finally {
currentThread.setContextClassLoader(cl);
}
if (ctx.shouldComplete()) {
break;
}
}
}
return request;
}
RegionCoprocessorHost.java 文件源码
项目:HIndex
阅读 35
收藏 0
点赞 0
评论 0
public void postEndpointInvocation(final Service service, final String methodName,
final Message request, final Message.Builder responseBuilder) throws IOException {
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
for (RegionEnvironment env : coprocessors) {
if (env.getInstance() instanceof EndpointObserver) {
ctx = ObserverContext.createAndPrepare(env, ctx);
Thread currentThread = Thread.currentThread();
ClassLoader cl = currentThread.getContextClassLoader();
try {
currentThread.setContextClassLoader(env.getClassLoader());
((EndpointObserver) env.getInstance()).postEndpointInvocation(ctx, service,
methodName, request, responseBuilder);
} catch (Throwable e) {
handleCoprocessorThrowable(env, e);
} finally {
currentThread.setContextClassLoader(cl);
}
if (ctx.shouldComplete()) {
break;
}
}
}
}
HTable.java 文件源码
项目:HIndex
阅读 27
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
throws ServiceException, Throwable {
final Map<byte[],R> results = Collections.synchronizedMap(
new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
public void update(byte[] region, byte[] row, R value) {
if (region != null) {
results.put(region, value);
}
}
});
return results;
}
ServiceRegistry.java 文件源码
项目:sstore-soft
阅读 33
收藏 0
点赞 0
评论 0
public void register(Service service) {
// TODO: Support registering multiple local services? Needs "local 2PC" effectively. Yuck.
Descriptors.ServiceDescriptor descriptor = service.getDescriptorForType();
for (MethodDescriptor i : descriptor.getMethods()) {
if (methods.containsKey(i.getFullName())) {
throw new IllegalStateException(
"method " + i.getFullName() + " is already registered");
}
methods.put(i.getFullName(), new ProtoMethodInvoker(service, i));
}
}
ServiceRegistry.java 文件源码
项目:s-store
阅读 25
收藏 0
点赞 0
评论 0
public void register(Service service) {
// TODO: Support registering multiple local services? Needs "local 2PC" effectively. Yuck.
Descriptors.ServiceDescriptor descriptor = service.getDescriptorForType();
for (MethodDescriptor i : descriptor.getMethods()) {
if (methods.containsKey(i.getFullName())) {
throw new IllegalStateException(
"method " + i.getFullName() + " is already registered");
}
methods.put(i.getFullName(), new ProtoMethodInvoker(service, i));
}
}
NrpcServiceRegistry.java 文件源码
项目:JavaNRPC
阅读 23
收藏 0
点赞 0
评论 0
public Service queryService(String serviceFullName) throws ServiceNotFoundException {
Service service = serviceMap.get(serviceFullName);
if (service == null) {
throw new ServiceNotFoundException("Not foud service : " + serviceFullName);
}
return service;
}
AccessController.java 文件源码
项目:ditb
阅读 27
收藏 0
点赞 0
评论 0
@Override
public Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx,
Service service, String methodName, Message request) throws IOException {
// Don't intercept calls to our own AccessControlService, we check for
// appropriate permissions in the service handlers
if (shouldCheckExecPermission && !(service instanceof AccessControlService)) {
requirePermission("invoke(" + service.getDescriptorForType().getName() + "." +
methodName + ")",
getTableName(ctx.getEnvironment()), null, null,
Action.EXEC);
}
return request;
}
RegionCoprocessorHost.java 文件源码
项目:ditb
阅读 30
收藏 0
点赞 0
评论 0
public Message preEndpointInvocation(final Service service, final String methodName,
Message request) throws IOException {
return execOperationWithResult(request,
coprocessors.isEmpty() ? null : new EndpointOperationWithResult<Message>() {
@Override
public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
throws IOException {
setResult(oserver.preEndpointInvocation(ctx, service, methodName, getResult()));
}
});
}
RegionCoprocessorHost.java 文件源码
项目:ditb
阅读 26
收藏 0
点赞 0
评论 0
public void postEndpointInvocation(final Service service, final String methodName,
final Message request, final Message.Builder responseBuilder) throws IOException {
execOperation(coprocessors.isEmpty() ? null : new EndpointOperation() {
@Override
public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
throws IOException {
oserver.postEndpointInvocation(ctx, service, methodName, request, responseBuilder);
}
});
}
HTablePool.java 文件源码
项目:ditb
阅读 39
收藏 0
点赞 0
评论 0
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service,
byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
throws ServiceException, Throwable {
checkState();
return table.coprocessorService(service, startKey, endKey, callable);
}
HTablePool.java 文件源码
项目:ditb
阅读 25
收藏 0
点赞 0
评论 0
@Override
public <T extends Service, R> void coprocessorService(Class<T> service,
byte[] startKey, byte[] endKey, Batch.Call<T, R> callable, Callback<R> callback)
throws ServiceException, Throwable {
checkState();
table.coprocessorService(service, startKey, endKey, callable, callback);
}
MockHTable.java 文件源码
项目:hgraphdb
阅读 28
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(final Class<T> service,
byte[] startKey, byte[] endKey, final Batch.Call<T, R> callable)
throws ServiceException {
throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
MockHTable.java 文件源码
项目:hgraphdb
阅读 27
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public <T extends Service, R> void coprocessorService(final Class<T> service,
byte[] startKey, byte[] endKey, final Batch.Call<T, R> callable,
final Batch.Callback<R> callback) throws ServiceException {
throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
AsyncHBaseExecutor.java 文件源码
项目:AbacusUtil
阅读 28
收藏 0
点赞 0
评论 0
<T extends Service, R> CompletableFuture<Map<byte[], R>> coprocessorService(final String tableName, final Class<T> service, final Object startRowKey,
final Object endRowKey, final Batch.Call<T, R> callable) throws Exception {
return asyncExecutor.execute(new Callable<Map<byte[], R>>() {
@Override
public Map<byte[], R> call() throws Exception {
return hbaseExecutor.coprocessorService(tableName, service, startRowKey, endRowKey, callable);
}
});
}
AsyncHBaseExecutor.java 文件源码
项目:AbacusUtil
阅读 27
收藏 0
点赞 0
评论 0
<T extends Service, R> CompletableFuture<Void> coprocessorService(final String tableName, final Class<T> service, final Object startRowKey,
final Object endRowKey, final Batch.Call<T, R> callable, final Batch.Callback<R> callback) throws Exception {
return asyncExecutor.execute(new Callable<Void>() {
@Override
public Void call() throws Exception {
hbaseExecutor.coprocessorService(tableName, service, startRowKey, endRowKey, callable, callback);
return null;
}
});
}
ServerRpcProvider.java 文件源码
项目:Wiab.pro
阅读 33
收藏 0
点赞 0
评论 0
/**
* Register all methods provided by the given service type.
*/
public void registerService(Service service) {
synchronized (registeredServices) {
for (MethodDescriptor methodDescriptor : service.getDescriptorForType().getMethods()) {
registeredServices.put(methodDescriptor.getInputType(),
new RegisteredServiceMethod(service, methodDescriptor));
}
}
}
BigtableTable.java 文件源码
项目:cloud-bigtable-client
阅读 32
收藏 0
点赞 0
评论 0
@Override
public <T extends Service, R> void coprocessorService(Class<T> service, byte[] startKey,
byte[] endKey, Batch.Call<T, R> callable, Batch.Callback<R> callback)
throws ServiceException, Throwable {
LOG.error("Unsupported coprocessorService("
+ "Class, byte[], byte[], Batch.Call, Batch.Callback) called.");
throw new UnsupportedOperationException(); // TODO
}