Пример #1
0
  @Override
  public void cmdExecute(Message msg, ServerConnection servConn, long start)
      throws IOException, ClassNotFoundException {
    servConn.setAsTrue(REQUIRES_RESPONSE);
    if (logger.fineEnabled()) {
      logger.fine(
          servConn.getName()
              + ": Received get pdx id for enum request ("
              + msg.getNumberOfParts()
              + " parts) from "
              + servConn.getSocketString());
    }
    int noOfParts = msg.getNumberOfParts();

    EnumInfo enumInfo = (EnumInfo) msg.getPart(0).getObject();
    int enumId = msg.getPart(1).getInt();

    try {
      GemFireCacheImpl cache = (GemFireCacheImpl) servConn.getCache();
      TypeRegistry registry = cache.getPdxRegistry();
      registry.addRemoteEnum(enumId, enumInfo);
    } catch (Exception e) {
      writeException(msg, e, false, servConn);
      servConn.setAsTrue(RESPONDED);
      return;
    }

    writeReply(msg, servConn);
    servConn.setAsTrue(RESPONDED);
  }
 /** Flush any pending writes. */
 @Override
 protected synchronized PdxReaderImpl getUnmodifiableReader() {
   if (this.dirtyFields != null) {
     PdxOutputStream os = new PdxOutputStream(basicSize() + PdxWriterImpl.HEADER_SIZE);
     PdxWriterImpl writer;
     if (getPdxType().getHasDeletedField()) {
       // Need a new type that does not have the deleted field
       PdxType pt = new PdxType(getPdxType().getClassName(), !getPdxType().getNoDomainClass());
       GemFireCacheImpl gfc =
           GemFireCacheImpl.getForPdx(
               "PDX registry is unavailable because the Cache has been closed.");
       TypeRegistry tr = gfc.getPdxRegistry();
       writer = new PdxWriterImpl(pt, tr, os);
     } else {
       writer = new PdxWriterImpl(getPdxType(), os);
     }
     for (PdxField f : getPdxType().getFields()) {
       if (f.isDeleted()) {
         continue;
       }
       Object dv = this.dirtyFields[f.getFieldIndex()];
       if (dv != null) {
         if (dv == NULL_TOKEN) {
           dv = null;
         }
         writer.writeField(f, dv);
       } else {
         writer.writeRawField(f, getRaw(f));
       }
     }
     writer.completeByteStreamGeneration();
     ByteBuffer bb = os.toByteBuffer();
     bb.position(PdxWriterImpl.HEADER_SIZE);
     basicSetBuffer(bb.slice());
     this.dirtyFields = null;
   }
   return new PdxReaderImpl(this);
 }