• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PdxInstance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convertObjToJsonString

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
public static String convertObjToJsonString(Object obj) {
  if (obj == null || (obj instanceof Map && ((Map)obj).isEmpty())) {
    return null;
  }
  
  if (obj instanceof Map) {
    return toJSON((Map)obj);
  }
  else if (obj instanceof List) {
    return toJSON((List)obj);
  }
  else if (obj instanceof PdxInstance) {
    return JSONFormatter.toJSON((PdxInstance)obj);
  }
  else {
    return obj.toString();
  }
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:JSONProcedures.java


示例2: toJSON

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
private static <K, V> String toJSON(Map map) {
  StringBuilder sb = new StringBuilder();
  String delim = "";
  for (Map.Entry<K, V> entry : ((Map<K, V>)map).entrySet()) {
    sb.append(delim);
    if (entry.getValue() instanceof PdxInstance) {
      sb.append(JSONFormatter.toJSON((PdxInstance)entry.getValue()));
      delim = ",\n";
    }
    else if (entry.getValue() instanceof List) {
      sb.append(toJSON((List)entry.getValue()));
      delim = ",\n";
    }
    else {
      sb.append(entry.getValue());
      delim = ",";
    }
  }
  return sb.toString();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:JSONProcedures.java


示例3: isWellKnownImmutableInstance

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Return true if the given object is an instance of a well known
 * immutable class.
 * The well known classes are:
 * <ul>
 * <li>String
 * <li>Byte
 * <li>Character
 * <li>Short
 * <li>Integer
 * <li>Long
 * <li>Float
 * <li>Double
 * <li>BigInteger
 * <li>BigDecimal
 * <li>UUID
 * <li>PdxInstance but not WritablePdxInstance
 * </ul>
 * @param o the object to check
 * @return true if o is an instance of a well known immutable class.
 * @since 6.6.2
 */
public static boolean isWellKnownImmutableInstance(Object o, Class<?> c) {
  if (c == String.class) {
    return true;
  }
  if (o instanceof Number) {
    if (c == Integer.class) return true;
    if (c == Long.class) return true;
    if (c == Byte.class) return true;
    if (c == Short.class) return true;
    if (c == Float.class) return true;
    if (c == Double.class) return true;
    // subclasses of non-final classes may be mutable
    if (c == BigInteger.class) return true;
    if (c == BigDecimal.class) return true;
  }
  if (o instanceof PdxInstance && !(o instanceof WritablePdxInstance)) {
    // no need to copy since it is immutable
    return true;
  }
  if (c == Character.class) return true;
  if (o instanceof UUID) return true;
  return false;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:46,代码来源:CopyHelper.java


示例4: pdxToJson

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
private static String pdxToJson(PdxInstance obj) {
  if(obj!=null){
    try{
      GfJsonObject json = new GfJsonObject();
      for(String field : obj.getFieldNames()){
        Object fieldValue = obj.getField(field);
        if(fieldValue!=null){
          if(JsonUtil.isPrimitiveOrWrapper(fieldValue.getClass())){
            json.put(field, fieldValue);
          }else{
            json.put(field, fieldValue.getClass());
          }
        }
      }
      return json.toString();
    }catch(GfJsonException e){        
      return null;
    }
  }
  return null;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:DataCommandFunction.java


示例5: readPdxEnum

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/**
 * @throws IOException
 * since 6.6.2
 */
private static Object readPdxEnum(DataInput in) throws IOException {
  int dsId = in.readByte();
  int tmp = readArrayLength(in);
  int enumId = (dsId << 24) | (tmp & 0xFFFFFF);
  if (DEBUG) {
    logger.info(LocalizedStrings.DEBUG, "read PdxEnum id=" + enumId);
  }
  GemFireCacheImpl gfc = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed.");
  TypeRegistry tr = gfc.getPdxRegistry();
  
  Object result = tr.getEnumById(enumId);
  if (result instanceof PdxInstance) {
    getDMStats(gfc).incPdxInstanceCreations();
  }
  return result;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:InternalDataSerializer.java


示例6: prepareValueForCache

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Prepares and returns a value to be stored in the cache.
 * Current prep is to make sure a PdxInstance is not stored in the cache
 * and to copy values into offheap memory of the region is using off heap storage.
 * 
 * @param r the region the prepared object will be stored in
 * @param val the value that will be stored
 * @return the prepared value
 */
public static Object prepareValueForCache(RegionEntryContext r, Object val) {
  Object nv = val;
  if (nv instanceof PdxInstance) {
    // We do not want to put PDXs in the cache as values.
    // So get the serialized bytes and use a CachedDeserializable.
    try {
      byte[] data = ((ConvertableToBytes)nv).toBytes();
      byte[] compressedData = compressBytes(r, data);
      if (data == compressedData) {
        nv = CachedDeserializableFactory.create(data);
      } else {
        nv = compressedData;
      }
    } catch (IOException e) {
      throw new PdxSerializationException("Could not convert " + nv + " to bytes", e);
    }
  } else {
    nv = AbstractRegionEntry.compress(r, nv);
  }
  return nv;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:AbstractRegionMap.java


示例7: create

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Creates and returns an instance of CachedDeserializable that contains the
 * specified object (that is not a byte[]).
 * 
 * Always check for {@link #preferObject()} before invoking this.
 */
public static CachedDeserializable create(Object object, int serializedSize) {
  Assert.assertTrue(!PREFER_RAW_OBJECT,
      "should not be invoked for gemfire.PREFER_RAW_OBJECT");
  if (STORE_ALL_VALUE_FORMS) {
    return new StoreAllCachedDeserializable(object);
  }
  else if (PREFER_DESERIALIZED) {
    if (object instanceof PdxInstance && cachePrefersPdx()) {
      return new PreferBytesCachedDeserializable(object);

    } else {
      return new VMCachedDeserializable(object, serializedSize);
    }
  } else {
    return new PreferBytesCachedDeserializable(object);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:CachedDeserializableFactory.java


示例8: checkEquals

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
static boolean checkEquals(@Unretained Object v1, @Unretained Object v2) {
  // need to give PdxInstance#equals priority
  if (v1 instanceof PdxInstance) {
    return checkPdxEquals((PdxInstance)v1, v2);
  } else if (v2 instanceof PdxInstance) {
    return checkPdxEquals((PdxInstance)v2, v1);
  } else if (v1 instanceof OffHeapCachedDeserializable) {
    return checkOffHeapEquals((OffHeapCachedDeserializable)v1, v2);
  } else if (v2 instanceof OffHeapCachedDeserializable) {
    return checkOffHeapEquals((OffHeapCachedDeserializable)v2, v1);
  } else if (v1 instanceof CachedDeserializable) {
    return checkCDEquals((CachedDeserializable)v1, v2);
  } else if (v2 instanceof CachedDeserializable) {
    return checkCDEquals((CachedDeserializable)v2, v1);
  } else {
    if (v2 != null) {
      return v2.equals(v1);
    } else {
      return v1 == null;
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:AbstractRegionEntry.java


示例9: verifyAndGetPdxDomainObject

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
private Object verifyAndGetPdxDomainObject(Object value) {
  if (value instanceof Struct) {
    // Doing hasPdx check first, since its cheaper.
    if (((StructImpl)value).isHasPdx() && !((GemFireCacheImpl)
        this.region.getCache()).getPdxReadSerializedByAnyGemFireServices()) {
      // Set the pdx values for the struct object.
      StructImpl v = (StructImpl)value;
      Object[] fieldValues = v.getPdxFieldValues();
      return new StructImpl((StructTypeImpl)v.getStructType(), fieldValues);
    }
  } else if (value instanceof PdxInstance && !((GemFireCacheImpl) 
      this.region.getCache()).getPdxReadSerializedByAnyGemFireServices()) {
    return ((PdxInstance)value).getObject();
  }
  return value;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:AbstractIndex.java


示例10: StructImpl

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/** Creates a new instance of StructImpl */
public StructImpl(StructTypeImpl type, Object[] values) {
  if (type == null) {
    throw new IllegalArgumentException(LocalizedStrings.StructImpl_TYPE_MUST_NOT_BE_NULL.toLocalizedString());
  }
  this.type = type;
  this.values = values;
  if (this.values != null) {
    for (Object o : values) {
      if (o instanceof PdxInstance || o instanceof PdxString) {
        this.hasPdx = true;
        break;
      } 
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:StructImpl.java


示例11: getPdxFieldValues

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Helper method, Returns field values, in case of PdxInstance 
 * gets the domain objects.
 */
public Object[] getPdxFieldValues() {
  if (this.values == null) {
    return new Object[0];
  }
  
  Object[] fValues = new Object[this.values.length];
  for (int i=0; i < this.values.length; i++) {
    if (this.values[i] instanceof PdxInstance) {
      fValues[i] = ((PdxInstance)this.values[i]).getObject();
    }
    else if (this.values[i] instanceof PdxString) {
      fValues[i] = ((PdxString)this.values[i]).toString();
    } else {
      fValues[i] = this.values[i];
    }
  }
  return fValues;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:StructImpl.java


示例12: startGUIUpdateThread

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
private void startGUIUpdateThread() {
  this.guiUpdateThread = new Thread("wanActiveActive GUI update thread") {
    public void run() {
      while (true) {
        try {
          Region region = CacheFactory.getAnyInstance().getRegion("/wanActiveActive");
          if (region != null) {
            PdxInstance serializedValue = (PdxInstance)region.get("MyValue");
            if (serializedValue != null) {
              dialog.setModification(Value.getModification(serializedValue));
              dialog.setHistory(Value.getHistory(serializedValue).toString());
            }
          }
          try { Thread.sleep(2000); } catch (InterruptedException e) { return; }
        } catch (CacheClosedException e) {
          return;
        } catch (RuntimeException e) {
          e.printStackTrace();
          return;
        }
      }
    }
  };
  this.guiUpdateThread.setDaemon(true);
  this.guiUpdateThread.start();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:WANConflictResolver.java


示例13: toBaseObject

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/** Given an object that can be a PdxInstance, return either the object or 
 *  the base object represented by the PdxInstance.
 * @param anObj The object that could be a PdxInstance
 * @return anObj, or if anObj is a PdxInstance return its base object.
 */
public static Object toBaseObject(Object anObj) {
  boolean expectPdxInstance = true;
  Cache aCache = CacheHelper.getCache();
  if (aCache != null) { // could be null during a nice_kill
    expectPdxInstance = aCache.getPdxReadSerialized();
  }
  if (anObj instanceof PdxInstance) {
    if (!expectPdxInstance) {
      throw new TestException("Did not expect a PdxInstance: " + anObj);
    }
    PdxInstance pdxInst = (PdxInstance)anObj;
    Object baseObj = pdxInst.getObject();
    Log.getLogWriter().info("Obtained " + baseObj + " from PdxInstance " + pdxInst);
    return baseObj;
  } else if (anObj == null) {
    return anObj;
  } else {
    // even if we expect PdxInstances, we might get a domain object if it
    // happens to be deserialized already in the cache
    return anObj;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:PdxTestVersionHelper.java


示例14: testPDXObject

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
public void testPDXObject() {
	final Properties props = new Properties();
	props.setProperty(DistributionConfig.MCAST_ADDRESS_NAME, "239.192.81.10");
	DistributedSystem.connect(props);
	Cache cache = new CacheFactory().create();
	PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
	Portfolio p = new Portfolio(2);
	pf.writeInt("ID", 111);
	pf.writeString("status", "active");
	pf.writeString("secId", "IBM");
	pf.writeObject("portfolio", p);
	PdxInstance pi = pf.create();

	TypedJson tJsonObj = new TypedJson(RESULT,pi);
	System.out.println(tJsonObj);
	cache.close();

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:TypedJsonJUnitTest.java


示例15: testNestedPDXObject

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
public void testNestedPDXObject() {
	final Properties props = new Properties();
	props.setProperty(DistributionConfig.MCAST_ADDRESS_NAME, "239.192.81.10");
	DistributedSystem.connect(props);
	Cache cache = new CacheFactory().create();

	PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);

	pf.writeInt("ID", 111);
	pf.writeString("status", "active");
	pf.writeString("secId", "IBM");
	PdxInstance pi = pf.create();

	PDXContainer cont = new PDXContainer(1);
	cont.setPi(pi);

	TypedJson tJsonObj = new TypedJson(RESULT,cont);
	System.out.println(tJsonObj);
	cache.close();

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:TypedJsonJUnitTest.java


示例16: putHeterogeneousObjects

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
public void putHeterogeneousObjects() throws Exception {
  PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio",
      false);
  pf.writeInt("ID", 111);
  pf.writeString("secId", "IBM");
  pf.writeString("status", "active");
  PdxInstance pi = pf.create();
  r.put("IBM", pi);

  r.put("YHOO", new TestObject(222, "YHOO","inactive"));
  r.put("GOOGL", new TestObject(333, "GOOGL","active"));

  pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
  pf.writeInt("ID", 111);
  pf.writeString("secId", "VMW");
  pf.writeString("status", "inactive");
  pi = pf.create();
  r.put("VMW", pi);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:PdxStringQueryJUnitTest.java


示例17: writeSnapshot

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Write the region snapshot to the BB (includes only persistent regions)
 */
protected void writeSnapshot() {
  Log.getLogWriter().info("Preparing to write snapshot for " + theRegion.getName());
  Map regionSnapshot = new HashMap();
  for (Object key: theRegion.keySet()) {
    Object value = null;
    if (theRegion.containsValueForKey(key)) { // won't invoke a loader (if any)
      value = theRegion.get(key);
    }
    if (value instanceof BaseValueHolder) {
      regionSnapshot.put(key, ((BaseValueHolder)value).myValue);
    } else if (value instanceof PdxInstance) {
      BaseValueHolder vh = PdxTest.toValueHolder(value);
      regionSnapshot.put(key, vh.myValue);
    } else {
      regionSnapshot.put(key, value);
    }
  } 
  Log.getLogWriter().info("Region snapshot for " + theRegion.getFullPath() + " is size " + regionSnapshot.size() + " and contains keys " + regionSnapshot.keySet());
  DeltaGIIBB.getBB().getSharedMap().put(DeltaGIIBB.regionSnapshotKey, regionSnapshot);
  Log.getLogWriter().info("vm_" + RemoteTestModule.getMyVmid() + " wrote snapshot for " + theRegion.getName() + " into blackboard at key " + DeltaGIIBB.regionSnapshotKey);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:DeltaGIITest.java


示例18: putSnapshot

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
/** Put a region snapshot into the blackboard. If the values in the snapshot
 *  are PdxSerializables they cannot be put to the blackboard since hydra
 *  MasterController does not have them on the classPath. In this case 
 *  make an alternate map with values being Maps of field/field values.
 *  Note: either all values are PdxSerializables or all values are not.
 * @param snapshot The snapshot to write to the blackboard; this might contain
 *        PdxSerializables. 
 */
public static void putSnapshot(Map snapshot) {
  Map alteredSnapshot = new HashMap();
  for (Object key: snapshot.keySet()) {
    Object value = snapshot.get(key);
    if (value == null) {
       alteredSnapshot.put(key, value);
    } else if (value instanceof PdxInstance) {
      alteredSnapshot.put(key, PdxTestVersionHelper.toBaseObject(value));
    } else { 
      String className = value.getClass().getName();
      if (className.equals("util.PdxVersionedQueryObject") ||
          className.equals("util.VersionedQueryObject")) {
        Map fieldMap = PdxTest.getFieldMap(value);
        alteredSnapshot.put(key, fieldMap);
      } else {
        alteredSnapshot.put(key, value);
      }
    }
  }
  CQUtilBB.getBB().getSharedMap().put(CQUtilBB.RegionSnapshot, alteredSnapshot);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:CQTestVersionHelper.java


示例19: handle

import com.gemstone.gemfire.pdx.PdxInstance; //导入依赖的package包/类
public void handle(Message<?> message){
	Message<?> transformedMessage = message;
	if (convertToJson) {
		Object payload = message.getPayload();

		if (payload instanceof String) {
			PdxInstance transformedPayload = transformer.toObject((String)payload);
			transformedMessage =  MessageBuilder
					.fromMessage(message)
					.withPayload(transformedPayload)
					.build();
		}
		else {
			throw new MessageConversionException(String.format(
					"Cannot convert object of type %s", payload.getClass()
							.getName()));
		}
	}
	messageHandler.handleMessage(transformedMessage);
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:gemfire,代码行数:21,代码来源:GemfireSinkHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpringTemplateLoader类代码示例发布时间:2022-05-22
下一篇:
Java IndexedEdge类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap