/** * Get a connection to the currently set master. * @return proxy connection to master server for this instance * @throws MasterNotRunningException if the master is not running * @throws ZooKeeperConnectionException if unable to connect to zookeeper * @deprecated Master is an implementation detail for HBaseAdmin. * Deprecated in HBase 0.94 */ @Deprecated public HMasterInterface getMaster() throws MasterNotRunningException, ZooKeeperConnectionException { return this.connection.getMaster(); }
/** * Constructor for externally managed HConnections. * This constructor fails fast if the HMaster is not running. * The HConnection can be re-used again in another attempt. * This constructor fails fast. * * @param connection The HConnection instance to use * @throws MasterNotRunningException if the master is not running * @throws ZooKeeperConnectionException if unable to connect to zookeeper */ public HBaseAdmin(HConnection connection) throws MasterNotRunningException, ZooKeeperConnectionException { this.conf = connection.getConfiguration(); this.connection = connection; this.pause = this.conf.getLong("hbase.client.pause", 1000); this.numRetries = this.conf.getInt("hbase.client.retries.number", 10); this.retryLongerMultiplier = this.conf.getInt( "hbase.client.retries.longer.multiplier", 10); this.connection.getMaster(); }
@Override public Object invoke(Object instance, final Method method, final Object[] args) throws Throwable { if (LOG.isDebugEnabled()) { LOG.debug("Call: "+method.getName()+", "+(args != null ? args.length : 0)); } Exec exec = new Exec(conf, protocol, method, args); ExecResult result = connection.getMaster().execCoprocessor(exec); LOG.debug("Master Result is value="+result.getValue()); return result.getValue(); } }
try { this.connection.getMaster(); return;
@Override protected Message callExecService(Descriptors.MethodDescriptor method, Message request, Message responsePrototype) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Call: "+method.getName()+", "+request.toString()); } final ClientProtos.CoprocessorServiceCall call = ClientProtos.CoprocessorServiceCall.newBuilder() .setRow(ByteStringer.wrap(HConstants.EMPTY_BYTE_ARRAY)) .setServiceName(method.getService().getFullName()) .setMethodName(method.getName()) .setRequest(request.toByteString()).build(); CoprocessorServiceResponse result = ProtobufUtil.execService(connection.getMaster(), call); Message response = null; if (result.getValue().hasValue()) { Message.Builder builder = responsePrototype.newBuilderForType(); ProtobufUtil.mergeFrom(builder, result.getValue().getValue()); response = builder.build(); } else { response = responsePrototype.getDefaultInstanceForType(); } if (LOG.isTraceEnabled()) { LOG.trace("Master Result is value=" + response); } return response; }