@Override public long expand(long size) { long ret = 0L; if (null != m_features) { if (m_features.contains(EXPANDABLE)) { ret = size; } else { throw new ConfigurationException("Do not support expand operation"); } } else { throw new ConfigurationException("Do not support features"); } return ret; }
@Override public long shrink(long size) { long ret = 0L; if (null != m_features) { if (m_features.contains(SHRINKABLE)) { ret = size; } else { throw new ConfigurationException("Do not support shrink operation"); } } else { throw new ConfigurationException("Do not support features"); } return ret; } }
public static void deleteFileOnly(String pathname) { File f = new File(pathname); if (f.isFile()) { if (!f.delete()) { throw new ConfigurationException(String.format("Failure to delete the file %s.", pathname)); } } }
@Override public long expand(long size) { long ret = 0L; if (null != m_features) { if (m_features.contains(MemoryServiceFeature.EXPANDABLE)) { ret = m_nvmasvc.adjustCapacity(m_nid, size); } else { throw new ConfigurationException("Do not support expand operation"); } } else { throw new ConfigurationException("Do not support features"); } return ret; }
@Override public long shrink(long size) { long ret = 0L; if (null != m_features) { if (m_features.contains(MemoryServiceFeature.SHRINKABLE)) { ret = m_nvmasvc.adjustCapacity(m_nid, (-1) * size); } else { throw new ConfigurationException("Do not support shrink operation"); } } else { throw new ConfigurationException("Do not support features"); } return ret; } }
@Override public long expand(long size) { long ret = 0L; if (null != m_features) { if (m_features.contains(MemoryServiceFeature.EXPANDABLE)) { ret = m_vmasvc.adjustCapacity(m_nid, size); } else { throw new ConfigurationException("Do not support expand operation"); } } else { throw new ConfigurationException("Do not support features"); } return ret; }
@Override public long shrink(long size) { long ret = 0L; if (null != m_features) { if (m_features.contains(MemoryServiceFeature.SHRINKABLE)) { ret = m_vmasvc.adjustCapacity(m_nid, (-1) * size); } else { throw new ConfigurationException("Do not support shrink operation"); } } else { throw new ConfigurationException("Do not support features"); } return ret; }
/** * instantiate an array of entity factory proxy classes. * * @param proxyclses * an array of entity factory proxy classes * * @return the array of instances */ public static EntityFactoryProxy[] instantiateEntityFactoryProxies(Class<?>[] proxyclses) { List<EntityFactoryProxy> ret = new ArrayList<EntityFactoryProxy>(); try { for (Class<?> itm : proxyclses) { if (EntityFactoryProxy.class.isAssignableFrom(itm)) { ret.add((EntityFactoryProxy)itm.newInstance()); } else { throw new ConfigurationException(String.format("%s is not EntityFactoryProxy", itm.getName())); } } } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException("Failed to instantiate assigned EntityFactoryProxy classes.", e); } return ret.toArray(new EntityFactoryProxy[0]); }
@Override public void initializeDurableEntity(A allocator, EntityFactoryProxy[] factoryProxy, DurableType[] gField, boolean autoReclaim, ReclaimContext rctx) { this.allocator = allocator; this.factoryProxy = factoryProxy; this.genericField = gField; this.autoReclaim = autoReclaim; this.reclaimcontext = rctx; DurableType gftypes[] = {DurableType.DURABLE}; this.listgftypes = ArrayUtils.addAll(gftypes, genericField); EntityFactoryProxy efproxies[] = new EntityFactoryProxy[0]; try { efproxies = new EntityFactoryProxy[]{ new EntityFactoryProxyHelper<MapEntry>(MapEntry.class, 1, reclaimcontext)}; } catch (ClassNotFoundException e) { throw new ConfigurationException("Class MapEntry not found"); } catch (NoSuchMethodException e) { throw new ConfigurationException("The methods of class MapEntry not found"); } this.listefproxies = ArrayUtils.addAll(efproxies, factoryProxy); try { this.unsafe = Utils.getUnsafe(); } catch (Exception e) { e.printStackTrace(); } }
public ChunkBuffer(DurableChunk<A> dchunk, long offset, int size) { Field address, capacity; m_dchunk = dchunk; if (null != dchunk && size > 0 && offset >= 0 && offset + size <= dchunk.getSize()) { ByteBuffer bb = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder()); try { address = Buffer.class.getDeclaredField("address"); address.setAccessible(true); capacity = Buffer.class.getDeclaredField("capacity"); capacity.setAccessible(true); address.setLong(bb, dchunk.get() + offset); capacity.setInt(bb, size); bb.limit(size); m_buffer = bb; m_offset = offset; m_size = size; } catch (NoSuchFieldException e) { throw new ConfigurationException("Buffer fields not found."); } catch (IllegalAccessException e) { throw new ConfigurationException("Buffer fields cannot be accessed."); } } else { throw new OutOfBoundsException("The ChunkBuffer is out of bounds of its backed DurableChunk."); } }
@Override public byte[] getAbstractAddress(long addr) { byte[] ret; if (useAbstractAddressing()) { ret = m_vmasvc.getAbstractAddress(addr); } else { throw new ConfigurationException("Do not support get abstract address operation"); } return ret; }
@Override public byte[] getAbstractAddress(long addr) { byte[] ret; if (useAbstractAddressing()) { ret = m_nvmasvc.getAbstractAddress(addr); } else { throw new ConfigurationException("Do not support get abstract address operation"); } return ret; }
/** * One session can only manage one iterator instance at a time for the simplicity * * @return the singleton iterator * */ @Override public SessionIterator<V, A, T, S> iterator() { SessionIterator<V, A, T, S> ret = new Intr(); if (!init(ret)) { throw new ConfigurationException("Input Session Iterator init. failure"); } return ret; }
throw new ConfigurationException("The specified memory service does not support volatile feature");
throw new ConfigurationException("The specified memory service does not support non-volatile feature");
if (null == m_act) { if (!initNextPool()) { throw new ConfigurationException("init next pool failure"); throw new ConfigurationException("try to init new next pool failure");
if (null == m_act) { if (!initNextPool()) { throw new ConfigurationException("init next pool failure in post");