Permalink
Browse files

Removed setter from standard CacheService interface and moved them to…

… MutableCacheService

git-svn-id: https://svn.apache.org/repos/asf/directmemory/trunk@1425900 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 45773f0 commit d630c54aef720336befcae178943eeee0787b523 @noctarius noctarius committed Dec 26, 2012
View
6 directmemory-cache/src/main/java/org/apache/directmemory/cache/CacheService.java
@@ -76,16 +76,10 @@
ConcurrentMap<K, Pointer<V>> getMap();
- void setMap( ConcurrentMap<K, Pointer<V>> map );
-
Serializer getSerializer();
MemoryManagerService<V> getMemoryManager();
- void setMemoryManager( MemoryManagerService<V> memoryManager );
-
- void setSerializer( Serializer serializer );
-
<T extends V> Pointer<V> allocate( K key, Class<T> type, int size );
}
View
2 directmemory-cache/src/main/java/org/apache/directmemory/cache/CacheServiceImpl.java
@@ -36,7 +36,7 @@
import static java.lang.String.format;
public class CacheServiceImpl<K, V>
- implements CacheService<K, V>
+ implements MutableCacheService<K, V>
{
private static Logger logger = LoggerFactory.getLogger( CacheServiceImpl.class );
View
38 directmemory-cache/src/main/java/org/apache/directmemory/cache/MutableCacheService.java
@@ -0,0 +1,38 @@
+package org.apache.directmemory.cache;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.directmemory.memory.MemoryManagerService;
+import org.apache.directmemory.memory.Pointer;
+import org.apache.directmemory.serialization.Serializer;
+
+public interface MutableCacheService<K, V>
+ extends CacheService<K, V>
+{
+
+ void setMap( ConcurrentMap<K, Pointer<V>> map );
+
+ void setMemoryManager( MemoryManagerService<V> memoryManager );
+
+ void setSerializer( Serializer serializer );
+
+}
View
18 integrations/solr/src/main/java/org/apache/directmemory/solr/SolrOffHeapCache.java
@@ -95,17 +95,10 @@ public Object init( Map args, Object persistence, CacheRegenerator regenerator )
String initialSizeValue = (String) args.get( "initialSize" );
final int initialSize = Math.min( initialSizeValue == null ? 1024 : Integer.parseInt( initialSizeValue ), limit );
-
- cacheService = new DirectMemory<K, V>()
- .setNumberOfBuffers( buffers != null ? Integer.valueOf( String.valueOf( buffers ) ) : 1 )
- .setInitialCapacity( Ram.Mb( Double.valueOf( initialSize ) / 512 ) )
- .setSize( Ram.Mb( limit / 512 ) )
- .newCacheService();
-
+ Serializer serializer = null;
String serializerClassName = (String) args.get( "serializerClassName" );
if ( serializerClassName != null )
{
- Serializer serializer;
try
{
serializer = SerializerFactory.createNewSerializer( serializerClassName );
@@ -116,10 +109,15 @@ public Object init( Map args, Object persistence, CacheRegenerator regenerator )
", falling back to the default serializer", e);
serializer = SerializerFactory.createNewSerializer();
}
-
- cacheService.setSerializer( serializer );
}
+ cacheService = new DirectMemory<K, V>()
+ .setNumberOfBuffers( buffers != null ? Integer.valueOf( String.valueOf( buffers ) ) : 1 )
+ .setInitialCapacity( Ram.Mb( Double.valueOf( initialSize ) / 512 ) )
+ .setSize( Ram.Mb( limit / 512 ) )
+ .setSerializer( serializer )
+ .newCacheService();
+
state = State.CREATED;
this.regenerator = regenerator;
name = (String) args.get( "name" );

0 comments on commit d630c54

Please sign in to comment.