当前位置: 首页>>代码示例>>Java>>正文


Java Descriptors类代码示例

本文整理汇总了Java中com.google.protobuf.Descriptors的典型用法代码示例。如果您正苦于以下问题:Java Descriptors类的具体用法?Java Descriptors怎么用?Java Descriptors使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Descriptors类属于com.google.protobuf包,在下文中一共展示了Descriptors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: batchCoprocessorService

import com.google.protobuf.Descriptors; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <R extends Message> Map<byte[], R> batchCoprocessorService(
    Descriptors.MethodDescriptor methodDescriptor, Message request,
    byte[] startKey, byte[] endKey, R responsePrototype) throws ServiceException, Throwable {
  final Map<byte[], R> results = Collections.synchronizedMap(new TreeMap<byte[], R>(
      Bytes.BYTES_COMPARATOR));
  batchCoprocessorService(methodDescriptor, request, startKey, endKey, responsePrototype,
      new Callback<R>() {

        @Override
        public void update(byte[] region, byte[] row, R result) {
          if (region != null) {
            results.put(region, result);
          }
        }
      });
  return results;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:HTable.java

示例2: decodeProtobuf

import com.google.protobuf.Descriptors; //导入依赖的package包/类
/**
 * Handle all the logic leading to the decoding of a Protobuf-encoded binary given a schema file path.
 * @param schema  Schema used to decode the binary data
 * @param messageType   Type of Protobuf Message
 * @param encodedData   Encoded data source
 * @return  A JSON representation of the data, contained in a Java String
 * @throws InvalidProtocolBufferException   Thrown when an error occurs during the encoding of the decoded data into JSON
 * @throws Descriptors.DescriptorValidationException    Thrown when the schema is invalid
 * @throws UnknownMessageTypeException  Thrown when the given message type is not contained in the schema
 * @throws MessageDecodingException Thrown when an error occurs during the binary decoding
 * @throws SchemaLoadingException   Thrown when an error occurs while reading the schema file
 */
public static String decodeProtobuf(DynamicSchema schema, String messageType, InputStream encodedData) throws InvalidProtocolBufferException, Descriptors.DescriptorValidationException, UnknownMessageTypeException, MessageDecodingException, SchemaLoadingException {
    Descriptors.Descriptor descriptor;
    DynamicMessage message;

    descriptor = schema.getMessageDescriptor(messageType);

    if (descriptor == null) {
        throw new UnknownMessageTypeException(messageType);
    }

    try {
        message = DynamicMessage.parseFrom(descriptor, encodedData);
    } catch (IOException e) {
        throw new MessageDecodingException(e);
    }

    return JSONMapper.toJSON(message);
}
 
开发者ID:whiver,项目名称:nifi-protobuf-processor,代码行数:31,代码来源:ProtobufService.java

示例3: registerService

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:HMaster.java

示例4: registerService

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:HRegionServer.java

示例5: registerService

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:HRegion.java

示例6: AsyncCall

import com.google.protobuf.Descriptors; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param eventLoop           for call
 * @param connectId           connection id
 * @param md                  the method descriptor
 * @param param               parameters to send to Server
 * @param controller          controller for response
 * @param responseDefaultType the default response type
 */
public AsyncCall(EventLoop eventLoop, int connectId, Descriptors.MethodDescriptor md, Message
    param, PayloadCarryingRpcController controller, Message responseDefaultType,
    MetricsConnection.CallStats callStats) {
  super(eventLoop);

  this.id = connectId;

  this.method = md;
  this.param = param;
  this.controller = controller;
  this.responseDefaultType = responseDefaultType;

  this.startTime = EnvironmentEdgeManager.currentTime();
  this.rpcTimeout = controller.hasCallTimeout() ? controller.getCallTimeout() : 0;
  this.callStats = callStats;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:AsyncCall.java

示例7: callMethod

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@Override
public void callMethod(Descriptors.MethodDescriptor md, RpcController controller,
    Message param, Message returnType, RpcCallback<Message> done) {
  PayloadCarryingRpcController pcrc;
  if (controller != null) {
    pcrc = (PayloadCarryingRpcController) controller;
    if (!pcrc.hasCallTimeout()) {
      pcrc.setCallTimeout(channelOperationTimeout);
    }
  } else {
    pcrc = new PayloadCarryingRpcController();
    pcrc.setCallTimeout(channelOperationTimeout);
  }

  this.rpcClient.callMethod(md, pcrc, param, returnType, this.ticket, this.isa, done);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:AsyncRpcClient.java

示例8: callBlockingMethod

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@Override
public Message callBlockingMethod(Descriptors.MethodDescriptor md, RpcController controller,
    Message param, Message returnType) throws ServiceException {
  PayloadCarryingRpcController pcrc;
  if (controller != null && controller instanceof PayloadCarryingRpcController) {
    pcrc = (PayloadCarryingRpcController) controller;
    if (!pcrc.hasCallTimeout()) {
      pcrc.setCallTimeout(channelOperationTimeout);
    }
  } else {
    pcrc = new PayloadCarryingRpcController();
    pcrc.setCallTimeout(channelOperationTimeout);
  }

  return this.rpcClient.callBlockingMethod(md, pcrc, param, returnType, this.ticket, this.isa);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:AbstractRpcClient.java

示例9: callMethod

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@Override
@InterfaceAudience.Private
public void callMethod(Descriptors.MethodDescriptor method,
                       RpcController controller,
                       Message request, Message responsePrototype,
                       RpcCallback<Message> callback) {
  Message response = null;
  try {
    response = callExecService(controller, method, request, responsePrototype);
  } catch (IOException ioe) {
    LOG.warn("Call failed on IOException", ioe);
    ResponseConverter.setControllerException(controller, ioe);
  }
  if (callback != null) {
    callback.run(response);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:CoprocessorRpcChannel.java

示例10: testUnpack

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@Test
public void testUnpack() throws InvalidProtocolBufferException {
    for (Descriptors.ServiceDescriptor serviceDescriptor : FyChessSi.getDescriptor().getServices()) {
        MethodDescriptor methodByName = serviceDescriptor.findMethodByName("onEnterRoom");
        if (methodByName != null) {
            GpbMessageDesc method = new GpbMessageDesc(methodByName);
            //
            VoEnterRoom message = VoEnterRoom.newBuilder()
                    .setRoomId(999)
                    .setSeat(8)
                    .build();
            Message unpack = method.unpack(message.toByteString());
            Message pack = method.pack(new Object[]{
                    999, 8, 10001L, "xx"
            });
            System.out.println();

        }
    }


}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:23,代码来源:GpbMessageDescTest.java

示例11: requireAllFieldsExcept

import com.google.protobuf.Descriptors; //导入依赖的package包/类
private static void requireAllFieldsExcept(AbstractMessage message, int... fieldNumbersNotRequired) {
    Collection<Descriptors.FieldDescriptor> required = new ArrayList<>(message.getDescriptorForType().getFields());
    Collection<Descriptors.FieldDescriptor> actual = message.getAllFields().keySet();
    required.removeAll(actual);
    if(fieldNumbersNotRequired != null) {
        for(int fieldNumber : fieldNumbersNotRequired) {
            required.remove(message.getDescriptorForType().findFieldByNumber(fieldNumber));
        }
    }
    if(!required.isEmpty()) {
        Collection<String> names = new ArrayList<>(required.size());
        for(Descriptors.FieldDescriptor desc : required) {
            names.add(desc.getName());
        }
        throw new ProtobufReadException(message.getDescriptorForType().getFullName(),
                                        "Missing required fields: " + names.toString());
    }
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:19,代码来源:ProtobufReader.java

示例12: messageForFilter

import com.google.protobuf.Descriptors; //导入依赖的package包/类
private static <M extends Message, B extends Message.Builder> M messageForFilter(
        ProtocolStringList filter,
        Constructor<B> builderConstructor, Message wholeMessage)
        throws InstantiationException,
               IllegalAccessException,
               InvocationTargetException {
    final B builder = builderConstructor.newInstance();

    final List<Descriptors.FieldDescriptor> fields = wholeMessage.getDescriptorForType()
                                                                 .getFields();
    for (Descriptors.FieldDescriptor field : fields) {
        if (filter.contains(field.getFullName())) {
            builder.setField(field, wholeMessage.getField(field));
        }
    }
    @SuppressWarnings("unchecked")
    // It's fine as the constructor is of {@code MessageCls.Builder} type.
    final M result = (M) builder.build();
    return result;
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:21,代码来源:FieldMasks.java

示例13: testDefaultValues

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@Test
public void testDefaultValues() throws Exception {

  Assert.assertEquals(9, defaultValueMap.size());
  Assert.assertEquals(
      "HOME",
      ((Descriptors.EnumValueDescriptor)defaultValueMap.get("util.Person.PhoneNumber.type")).getName()
  );
  Assert.assertEquals("engineering", defaultValueMap.get("util.Engineer.depName"));

  Assert.assertEquals("NY", defaultValueMap.get("util.Employee.stringField"));
  Assert.assertEquals(43243, defaultValueMap.get("util.Employee.intField"));
  Assert.assertEquals(3534.234, defaultValueMap.get("util.Employee.doubleField"));
  Assert.assertEquals(true, defaultValueMap.get("util.Employee.boolField"));
  Assert.assertEquals(343.34f, defaultValueMap.get("util.Employee.floatField"));
  Assert.assertEquals(2343254354L, defaultValueMap.get("util.Employee.longField"));
  Assert.assertTrue(
      Arrays.equals(
          "NewYork".getBytes(),
          ((ByteString) defaultValueMap.get("util.Employee.bytesField")).toByteArray()
      )
  );
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:24,代码来源:TestProtobufTypeUtil.java

示例14: read_single_record_with_mask

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions") // Converter nullability issues
@Test
public void read_single_record_with_mask() {
    final I id = newId();
    final EntityRecord record = newStorageRecord(id);
    final RecordStorage<I> storage = getStorage();
    storage.write(id, record);

    final Descriptors.Descriptor descriptor = newState(id).getDescriptorForType();
    final FieldMask idMask = FieldMasks.maskOf(descriptor, 1);

    final RecordReadRequest<I> readRequest = new RecordReadRequest<>(id);
    final Optional<EntityRecord> optional = storage.read(readRequest, idMask);
    assertTrue(optional.isPresent());
    final EntityRecord entityRecord = optional.get();

    final Message unpacked = unpack(entityRecord.getState());
    assertFalse(isDefault(unpacked));
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:20,代码来源:RecordStorageShould.java

示例15: register_aggregate_repositories

import com.google.protobuf.Descriptors; //导入依赖的package包/类
@Test
public void register_aggregate_repositories() {
    final BoundedContext boundedContext = BoundedContext.newBuilder()
                                                        .build();
    final Stand stand = boundedContext.getStand();

    checkTypesEmpty(stand);

    final CustomerAggregateRepository customerAggregateRepo =
            new CustomerAggregateRepository();
    stand.registerTypeSupplier(customerAggregateRepo);

    final Descriptors.Descriptor customerEntityDescriptor = Customer.getDescriptor();
    checkHasExactlyOne(stand.getExposedTypes(), customerEntityDescriptor);
    checkHasExactlyOne(stand.getExposedAggregateTypes(), customerEntityDescriptor);

    @SuppressWarnings("LocalVariableNamingConvention")
    final CustomerAggregateRepository anotherCustomerAggregateRepo =
            new CustomerAggregateRepository();
    stand.registerTypeSupplier(anotherCustomerAggregateRepo);
    checkHasExactlyOne(stand.getExposedTypes(), customerEntityDescriptor);
    checkHasExactlyOne(stand.getExposedAggregateTypes(), customerEntityDescriptor);
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:24,代码来源:StandShould.java


注:本文中的com.google.protobuf.Descriptors类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。