1 46 52 package org.mr.core.persistent; 53 54 import java.io.File ; 55 56 import org.mr.MantaAgent; 57 import org.mr.core.log.StartupLogger; 58 import org.mr.core.util.byteable.ByteBufferFactory; 59 import org.apache.commons.logging.LogFactory; 60 61 62 69 public class PersistentConst { 70 private static String PersistentDir; 72 private static boolean created =false; 73 private static ByteBufferFactory persistentByteBufferPool; 74 75 76 77 80 public static ByteBufferFactory getPersistentByteBufferPool() { 81 return persistentByteBufferPool; 82 } 83 84 87 public static void setPersistentByteBufferPool(ByteBufferFactory persistentByteBufferPool) { 88 PersistentConst.persistentByteBufferPool = persistentByteBufferPool; 89 } 90 91 96 public static String getPersistentDir(String persistentName) { 97 String specialDir = MantaAgent.getInstance().getSingletonRepository().getConfigManager().getStringProperty(persistentName); 98 if(specialDir != null){ 99 return specialDir; 100 } 101 102 createPersistentFolderIfNeeded(PersistentDir); 103 104 return PersistentDir; 105 } 106 107 111 public static void setPersistentDir(String persistentDir) { 112 PersistentConst.PersistentDir = persistentDir; 113 } 114 115 119 private static void createPersistentFolderIfNeeded(String persistentDir){ 120 if(!created){ 121 File dir =new File (persistentDir); 122 if(dir.exists() == false){ 123 StartupLogger.log.info("Persistent folder does not exist, creating persistent folder at "+persistentDir, "PersistentConst"); 126 dir.mkdir(); 127 }else{ 128 StartupLogger.log.info("Persistent folder found at "+persistentDir, "PersistentConst"); 131 } 132 created = true; 133 } 134 135 } 136 } 137 | Popular Tags |