本文整理汇总了Java中org.apache.hadoop.hbase.ipc.CoprocessorProtocol类的典型用法代码示例。如果您正苦于以下问题:Java CoprocessorProtocol类的具体用法?Java CoprocessorProtocol怎么用?Java CoprocessorProtocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CoprocessorProtocol类属于org.apache.hadoop.hbase.ipc包,在下文中一共展示了CoprocessorProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerProtocol
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public <T extends CoprocessorProtocol> boolean registerProtocol(
Class<T> protocol, T handler) {
/* No stacking of protocol handlers is currently allowed. The
* first to claim wins!
*/
if (protocolHandlers.containsKey(protocol)) {
LOG.error("Protocol "+protocol.getName()+
" already registered, rejecting request from "+
handler
);
return false;
}
protocolHandlers.putInstance(protocol, handler);
protocolHandlerNames.put(protocol.getName(), protocol);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered master protocol handler: protocol="+protocol.getName());
}
return true;
}
示例2: registerProtocol
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
/**
* Registers a new CoprocessorProtocol subclass and instance to be available for handling
* {@link HRegion#exec(Exec)} calls.
* <p>
* Only a single protocol type/handler combination may be registered per region. After the first
* registration, subsequent calls with the same protocol type will fail with a return value of
* {@code false}.
* </p>
* @param protocol a {@code CoprocessorProtocol} subinterface defining the protocol methods
* @param handler an instance implementing the interface
* @param <T> the protocol type
* @return {@code true} if the registration was successful, {@code false} otherwise
*/
public <T extends CoprocessorProtocol> boolean registerProtocol(Class<T> protocol, T handler) {
/*
* No stacking of protocol handlers is currently allowed. The first to claim wins!
*/
if (protocolHandlers.containsKey(protocol)) {
LOG.error("Protocol " + protocol.getName() + " already registered, rejecting request from "
+ handler);
return false;
}
protocolHandlers.putInstance(protocol, handler);
protocolHandlerNames.put(protocol.getName(), protocol);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered protocol handler: region=" + Bytes.toStringBinary(getRegionName())
+ " protocol=" + protocol.getName());
}
return true;
}
示例3: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T extends CoprocessorProtocol, R> Map<byte[],R> coprocessorExec(
Class<T> protocol, byte[] startKey, byte[] endKey,
Batch.Call<T,R> callable)
throws IOException, Throwable {
final Map<byte[],R> results = Collections.synchronizedMap(new TreeMap<byte[],R>(
Bytes.BYTES_COMPARATOR));
coprocessorExec(protocol, startKey, endKey, callable,
new Batch.Callback<R>(){
public void update(byte[] region, byte[] row, R value) {
results.put(region, value);
}
});
return results;
}
示例4: registerProtocol
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
/**
* Registers a new CoprocessorProtocol subclass and instance to
* be available for handling {@link HRegion#exec(Exec)} calls.
*
* <p>
* Only a single protocol type/handler combination may be registered per
* region.
* After the first registration, subsequent calls with the same protocol type
* will fail with a return value of {@code false}.
* </p>
* @param protocol a {@code CoprocessorProtocol} subinterface defining the
* protocol methods
* @param handler an instance implementing the interface
* @param <T> the protocol type
* @return {@code true} if the registration was successful, {@code false}
* otherwise
*/
public <T extends CoprocessorProtocol> boolean registerProtocol(
Class<T> protocol, T handler) {
/* No stacking of protocol handlers is currently allowed. The
* first to claim wins!
*/
if (protocolHandlers.containsKey(protocol)) {
LOG.error("Protocol "+protocol.getName()+
" already registered, rejecting request from "+
handler
);
return false;
}
protocolHandlers.putInstance(protocol, handler);
protocolHandlerNames.put(protocol.getName(), protocol);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered protocol handler: region="+
Bytes.toStringBinary(getRegionName())+" protocol="+protocol.getName());
}
return true;
}
示例5: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T extends CoprocessorProtocol, R> Map<byte[],R> coprocessorExec(
Class<T> protocol, byte[] startKey, byte[] endKey,
Batch.Call<T,R> callable)
throws IOException, Throwable {
final Map<byte[],R> results = new TreeMap<byte[],R>(
Bytes.BYTES_COMPARATOR);
coprocessorExec(protocol, startKey, endKey, callable,
new Batch.Callback<R>(){
public void update(byte[] region, byte[] row, R value) {
results.put(region, value);
}
});
return results;
}
示例6: createEnvironment
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public RegionEnvironment createEnvironment(Class<?> implClass,
Coprocessor instance, int priority, int seq, Configuration conf) {
// Check if it's an Endpoint.
// Due to current dynamic protocol design, Endpoint
// uses a different way to be registered and executed.
// It uses a visitor pattern to invoke registered Endpoint
// method.
for (Class c : implClass.getInterfaces()) {
if (CoprocessorProtocol.class.isAssignableFrom(c)) {
region.registerProtocol(c, (CoprocessorProtocol)instance);
break;
}
}
return new RegionEnvironment(instance, priority, seq, conf, region,
rsServices);
}
示例7: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(Class<T> protocol,
byte[] startKey, byte[] endKey, Batch.Call<T, R> callable) throws IOException, Throwable {
final Map<byte[], R> results =
Collections.synchronizedMap(new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
coprocessorExec(protocol, startKey, endKey, callable, new Batch.Callback<R>() {
public void update(byte[] region, byte[] row, R value) {
results.put(region, value);
}
});
return results;
}
示例8: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public <T extends CoprocessorProtocol, R> void coprocessorExec(
Class<T> protocol, byte[] startKey, byte[] endKey,
Batch.Call<T, R> callable, Batch.Callback<R> callback)
throws IOException, Throwable {
table.coprocessorExec(protocol, startKey, endKey, callable, callback);
}
示例9: forMethod
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
/**
* Creates a new {@link Batch.Call} instance that invokes a method
* with the given parameters and returns the result.
*
* @param method the method reference to invoke
* @param args zero or more arguments to be passed to the method
* @param <T> the class type of the protocol implementation being invoked
* @param <R> the return type for the method call
* @return a {@code Callable} instance that will invoke the given method and
* return the results
* @see org.apache.hadoop.hbase.client.HTable#coprocessorExec(Class, byte[], byte[], org.apache.hadoop.hbase.client.coprocessor.Batch.Call, org.apache.hadoop.hbase.client.coprocessor.Batch.Callback)
*/
public static <T extends CoprocessorProtocol,R> Call<T,R> forMethod(
final Method method, final Object... args) {
return new Call<T,R>() {
public R call(T instance) throws IOException {
try {
if (Proxy.isProxyClass(instance.getClass())) {
InvocationHandler invoker = Proxy.getInvocationHandler(instance);
return (R)invoker.invoke(instance, method, args);
} else {
LOG.warn("Non proxied invocation of method '"+method.getName()+"'!");
return (R)method.invoke(instance, args);
}
}
catch (IllegalAccessException iae) {
throw new IOException("Unable to invoke method '"+
method.getName()+"'", iae);
}
catch (InvocationTargetException ite) {
throw new IOException(ite.toString(), ite);
}
catch (Throwable t) {
throw new IOException(t.toString(), t);
}
}
};
}
示例10: Exec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
public Exec(Configuration configuration,
byte[] row,
Class<? extends CoprocessorProtocol> protocol,
Method method, Object[] parameters) {
super(method, protocol, parameters);
this.conf = configuration;
this.referenceRow = row;
this.protocol = protocol;
this.protocolName = protocol.getName();
}
示例11: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(
Class<T> protocol, byte[] startKey, byte[] endKey,
Batch.Call<T, R> callable)
throws IOException, Throwable {
throw new UnsupportedOperationException("coprocessorExec not implemented");
}
示例12: createEnvironment
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public MasterEnvironment createEnvironment(final Class<?> implClass,
final Coprocessor instance, final int priority, final int seq,
final Configuration conf) {
for (Class c : implClass.getInterfaces()) {
if (CoprocessorProtocol.class.isAssignableFrom(c)) {
masterServices.registerProtocol(c, (CoprocessorProtocol)instance);
break;
}
}
return new MasterEnvironment(implClass, instance, priority, seq, conf,
masterServices);
}
示例13: createEnvironment
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public RegionEnvironment createEnvironment(Class<?> implClass,
Coprocessor instance, int priority, int seq, Configuration conf) {
// Check if it's an Endpoint.
// Due to current dynamic protocol design, Endpoint
// uses a different way to be registered and executed.
// It uses a visitor pattern to invoke registered Endpoint
// method.
for (Class c : implClass.getInterfaces()) {
if (CoprocessorProtocol.class.isAssignableFrom(c)) {
region.registerProtocol(c, (CoprocessorProtocol)instance);
break;
}
}
ConcurrentMap<String, Object> classData;
// make sure only one thread can add maps
synchronized (sharedDataMap) {
// as long as at least one RegionEnvironment holds on to its classData it will
// remain in this map
classData = (ConcurrentMap<String, Object>)sharedDataMap.get(implClass.getName());
if (classData == null) {
classData = new ConcurrentHashMap<String, Object>();
sharedDataMap.put(implClass.getName(), classData);
}
}
return new RegionEnvironment(instance, priority, seq, conf, region,
rsServices, classData);
}
示例14: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
@Override
public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(
Class<T> protocol, byte[] startKey, byte[] endKey, Call<T, R> callable) throws IOException,
Throwable {
// TODO Auto-generated method stub
return null;
}
示例15: coprocessorExec
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; //导入依赖的package包/类
public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(
String tableName, Class<T> paramClass, byte[] paramArrayOfByte1,
byte[] paramArrayOfByte2, Call<T, R> paramCall) throws IOException,
Throwable {
return poolableHConnection.coprocessorExec(tableName, paramClass,
paramArrayOfByte1, paramArrayOfByte2, paramCall);
}