View Javadoc

1   package org.apache.directmemory.memory;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Collection;
23  import java.util.HashSet;
24  
25  import org.apache.directmemory.memory.allocator.Allocator;
26  import org.apache.directmemory.memory.allocator.FixedSizeByteBufferAllocatorImpl;
27  import org.apache.directmemory.memory.allocator.SlabByteBufferAllocator;
28  import org.junit.Test;
29  
30  public class SlabMemoryManagerServiceTest
31      extends AbstractMemoryManagerServiceTest
32  {
33  
34      @Override
35      protected MemoryManagerService<Object> instanciateMemoryManagerService( int bufferSize )
36      {
37          final MemoryManagerService<Object> mms = new MemoryManagerServiceImpl<Object>()
38          {
39  
40              @Override
41              protected Allocator instanciateByteBufferAllocator( int allocatorNumber, int size )
42              {
43                  Collection<FixedSizeByteBufferAllocatorImpl> slabs = new HashSet<FixedSizeByteBufferAllocatorImpl>();
44  
45                  slabs.add( new FixedSizeByteBufferAllocatorImpl( 0, size, SMALL_PAYLOAD_LENGTH / 2, 1 ) );
46                  slabs.add( new FixedSizeByteBufferAllocatorImpl( 1, size, SMALL_PAYLOAD_LENGTH, 1 ) );
47                  slabs.add( new FixedSizeByteBufferAllocatorImpl( 2, size, SMALL_PAYLOAD_LENGTH * 2, 1 ) );
48  
49                  final SlabByteBufferAllocator allocator =
50                      new SlabByteBufferAllocator( allocatorNumber, slabs, false );
51  
52                  return allocator;
53              }
54  
55          };
56          mms.init( 1, bufferSize );
57          return mms;
58      }
59  
60      @Override
61      @Test
62      public void testFullFillAndFreeAndClearBuffer()
63      {
64  
65      }
66  
67      @Override
68      @Test
69      public void testStoreAllocAndFree()
70      {
71  
72      }
73  
74      @Override
75      @Test
76      public void testAllocate()
77      {
78  
79      }
80  
81  }