|
15 | 15 |
|
16 | 16 | package org.apache.fluo.core.impl;
|
17 | 17 |
|
| 18 | +import java.util.concurrent.TimeUnit; |
| 19 | + |
18 | 20 | import org.apache.fluo.api.config.FluoConfiguration;
|
19 | 21 |
|
20 | 22 | /**
|
@@ -102,6 +104,46 @@ public static int getTxCommitMemory(FluoConfiguration conf) {
|
102 | 104 | return m;
|
103 | 105 | }
|
104 | 106 |
|
| 107 | + public static final String TX_INFO_CACHE_SIZE = FLUO_IMPL_PREFIX + ".tx.failed.cache.size.mb"; |
| 108 | + public static final long TX_INFO_CACHE_SIZE_DEFAULT = 10000000; |
| 109 | + |
| 110 | + /** |
| 111 | + * Gets the cache size |
| 112 | + * |
| 113 | + * @param conf The FluoConfiguration |
| 114 | + * @return The size of the cache value from the property value {@value #TX_INFO_CACHE_SIZE} |
| 115 | + * if it is set, else the value of the default value {@value #TX_INFO_CACHE_SIZE_DEFAULT} |
| 116 | + */ |
| 117 | + |
| 118 | + public static long getTxInfoCacheSize(FluoConfiguration conf) { |
| 119 | + long size = conf.getLong(TX_INFO_CACHE_SIZE, TX_INFO_CACHE_SIZE_DEFAULT); |
| 120 | + if (size <= 0) { |
| 121 | + throw new IllegalArgumentException("Cache size must be positive for " + TX_INFO_CACHE_SIZE); |
| 122 | + } |
| 123 | + return size; |
| 124 | + } |
| 125 | + |
| 126 | + public static final String TX_INFO_CACHE_TIMEOUT = |
| 127 | + FLUO_IMPL_PREFIX + ".tx.failed.cache.expireTime.ms"; |
| 128 | + public static final long TX_INFO_CACHE_TIMEOUT_DEFAULT = 24 * 60 * 1000; |
| 129 | + |
| 130 | + /** |
| 131 | + * Gets the time before stale entries in the cache are evicted based on age. |
| 132 | + * This method returns a long representing the time converted from the |
| 133 | + * TimeUnit passed in. |
| 134 | + * |
| 135 | + * @param conf The FluoConfiguration |
| 136 | + * @param tu The TimeUnit desired to represent the cache timeout |
| 137 | + */ |
| 138 | + |
| 139 | + public static long getTxIfoCacheTimeout(FluoConfiguration conf, TimeUnit tu) { |
| 140 | + long millis = conf.getLong(TX_INFO_CACHE_TIMEOUT, TX_INFO_CACHE_TIMEOUT_DEFAULT); |
| 141 | + if (millis <= 0) { |
| 142 | + throw new IllegalArgumentException("Timeout must positive for " + TX_INFO_CACHE_TIMEOUT); |
| 143 | + } |
| 144 | + return tu.convert(millis, TimeUnit.MILLISECONDS); |
| 145 | + } |
| 146 | + |
105 | 147 | public static final String ASYNC_CW_THREADS = FLUO_IMPL_PREFIX + ".async.cw.threads";
|
106 | 148 | public static final int ASYNC_CW_THREADS_DEFAULT = 8;
|
107 | 149 | public static final String ASYNC_CW_LIMIT = FLUO_IMPL_PREFIX + ".async.cw.limit";
|
|
0 commit comments