IoTDBConfigDynamicAdapter implements IDynamicAdapter { @Override public void addOrDeleteTimeSeries(int diff) throws ConfigAdjusterException { if (!CONFIG.isEnableParameterAdapter()) { return; } totalTimeseries += diff; staticMemory += diff * TIMESERIES_METADATA_SIZE_IN_BYTE; if (!tryToAdaptParameters()) { totalTimeseries -= diff; staticMemory -= diff * TIMESERIES_METADATA_SIZE_IN_BYTE; throw new ConfigAdjusterException(ADD_TIMESERIES); } } private  IoTDBConfigDynamicAdapter(); static void setChunkMetadataSizeInByte(long chunkMetadataSizeInByte); static IoTDBConfigDynamicAdapter getInstance(); @Override synchronized boolean tryToAdaptParameters(); @Override void addOrDeleteStorageGroup(int diff); @Override void addOrDeleteTimeSeries(int diff); void setInitialized(boolean initialized); int getTotalTimeseries(); int getTotalStorageGroup(); void reset(); static final String CREATE_STORAGE_GROUP; static final String ADD_TIMESERIES; static final int MEMTABLE_NUM_FOR_EACH_PARTITION; }
@Test public void addOrDeleteTimeSeries() throws ConfigAdjusterException { int totalTimeseries = 0; for (int i = 1; i < 100; i++) { IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(1); } IoTDB.metaManager.setMaxSeriesNumberAmongStorageGroup(100); for (int i = 1; i < 1000000; i++) { try { IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1); if (i % 10 == 0) { IoTDB.metaManager.setMaxSeriesNumberAmongStorageGroup(i); } totalTimeseries += 1; assertEquals(IoTDBConfigDynamicAdapter.getInstance().getCurrentMemTableSize(), CONFIG.getMemtableSizeThreshold()); assertEquals(IoTDBConfigDynamicAdapter.getInstance().getTotalTimeseries(), totalTimeseries); } catch (ConfigAdjusterException e) { assertEquals(String.format(ConfigAdjusterException.ERROR_MSG_FORMAT, IoTDBConfigDynamicAdapter.ADD_TIMESERIES), e.getMessage()); assertEquals(IoTDBConfigDynamicAdapter.getInstance().getTotalTimeseries(), totalTimeseries); break; } } }