コード例 #1
0
 public static void init() throws Exception {
   Properties props = new Properties();
   int pid = OSProcess.getId();
   String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath();
   /** * Return file as string and then modify the string accordingly ** */
   String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"));
   file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid);
   String modified_file_str = modifyFile(file_as_str);
   FileOutputStream fos = new FileOutputStream(path);
   BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos));
   wr.write(modified_file_str);
   wr.flush();
   wr.close();
   props.setProperty("cache-xml-file", path);
   //    String tableName = "";
   //		  props.setProperty("mcast-port", "10339");
   try {
     //			   ds = DistributedSystem.connect(props);
     ds = (new ExceptionsDUnitTest("temp")).getSystem(props);
     cache = CacheFactory.create(ds);
   } catch (Exception e) {
     e.printStackTrace(System.err);
     throw new Exception("" + e);
   }
 }
コード例 #2
0
 public static void startCache() {
   try {
     if (cache == null || cache.isClosed()) {
       cache = CacheFactory.create(ds);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #3
0
 public static void closeCache() {
   try {
     if (cache != null && !cache.isClosed()) {
       cache.close();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   try {
     if (ds != null) ds.disconnect();
   } catch (Exception e) {
     getLogWriter().fine("Error in disconnecting from Distributed System");
   }
 }