@@ -62,6 +62,7 @@ public class EVCacheClientPool implements Runnable, EVCacheClientPoolMBean {
62
62
63
63
private final DynamicIntProperty logOperations ;
64
64
private final DynamicStringSetProperty logOperationCalls ;
65
+ private final DynamicStringSetProperty cloneWrite ;
65
66
66
67
private final DynamicIntProperty _opQueueMaxBlockTime ; // Timeout for adding an operation
67
68
private final DynamicIntProperty _operationTimeout ;// Timeout for write operation
@@ -157,6 +158,12 @@ public void run() {
157
158
this .logOperations = config .getDynamicIntProperty (appName + ".log.operation" , 0 );
158
159
this .logOperationCalls = new DynamicStringSetProperty (appName + ".log.operation.calls" , "SET,DELETE,GMISS,TMISS,BMISS_ALL,TOUCH,REPLACE" );
159
160
this .reconcileInterval = config .getDynamicIntProperty (appName + ".reconcile.interval" , 600000 );
161
+ this .cloneWrite = new DynamicStringSetProperty (appName + ".clone.writes.to" , "" );
162
+ this .cloneWrite .addCallback (new Runnable () {
163
+ public void run () {
164
+ setupClones ();
165
+ }
166
+ });
160
167
161
168
final Map <String , String > map = new HashMap <String , String >();
162
169
map .put ("APP" , _appName );
@@ -167,6 +174,12 @@ public void run() {
167
174
if (log .isInfoEnabled ()) log .info (toString ());
168
175
}
169
176
177
+ private void setupClones () {
178
+ for (String cloneApp : cloneWrite .get ()) {
179
+ manager .initEVCache (cloneApp );
180
+ }
181
+ }
182
+
170
183
private void clearState () {
171
184
cleanupMemcachedInstances (true );
172
185
memcachedInstancesByServerGroup .clear ();
@@ -295,7 +308,7 @@ public List<EVCacheClient> getEVCacheClientsForReadExcluding(ServerGroup serverG
295
308
}
296
309
return Collections .<EVCacheClient > emptyList ();
297
310
}
298
-
311
+
299
312
public boolean isInWriteOnly (ServerGroup serverGroup ) {
300
313
if (memcachedReadInstancesByServerGroup .containsKey (serverGroup )) {
301
314
return false ;
@@ -330,7 +343,7 @@ public EVCacheClient[] getWriteOnlyEVCacheClients() {
330
343
}
331
344
}
332
345
333
- public EVCacheClient [] getEVCacheClientForWrite () {
346
+ EVCacheClient [] getAllWriteClients () {
334
347
try {
335
348
final EVCacheClient [] clientArr = new EVCacheClient [memcachedWriteInstancesByServerGroup .size ()];
336
349
int i = 0 ;
@@ -351,6 +364,31 @@ public EVCacheClient[] getEVCacheClientForWrite() {
351
364
}
352
365
}
353
366
367
+
368
+ public EVCacheClient [] getEVCacheClientForWrite () {
369
+ try {
370
+ if ((cloneWrite .get ().size () == 0 )) {
371
+ return getAllWriteClients ();
372
+ } else {
373
+ final List <EVCacheClient > evcacheClientList = new ArrayList <EVCacheClient >();
374
+ final EVCacheClient [] clientArr = getAllWriteClients ();
375
+ for (EVCacheClient client : clientArr ) {
376
+ evcacheClientList .add (client );
377
+ }
378
+ for (String cloneApp : cloneWrite .get ()) {
379
+ final EVCacheClient [] cloneWriteArray = manager .getEVCacheClientPool (cloneApp ).getAllWriteClients ();
380
+ for (int j = 0 ; j < cloneWriteArray .length ; j ++) {
381
+ evcacheClientList .add (cloneWriteArray [j ]);
382
+ }
383
+ }
384
+ return evcacheClientList .toArray (new EVCacheClient [0 ]);
385
+ }
386
+ } catch (Throwable t ) {
387
+ log .error ("Exception trying to get an array of writable EVCache Instances" , t );
388
+ return new EVCacheClient [0 ];
389
+ }
390
+ }
391
+
354
392
private void refresh () throws IOException {
355
393
refresh (false );
356
394
}
0 commit comments