Michael Blow has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1153
Change subject: Expose Asterix Configuration on Cluster Servlet ...................................................................... Expose Asterix Configuration on Cluster Servlet Change-Id: I828d6a61afe615f7826079ede4b1d638bbd7ac5d --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractAsterixProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixCompilerProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExternalProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixFeedProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixStorageProperties.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixTransactionProperties.java 8 files changed, 165 insertions(+), 38 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/53/1153/1 diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java index c7cf1ea..8a16cd7 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java @@ -20,12 +20,16 @@ import java.io.IOException; import java.io.PrintWriter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.asterix.app.result.ResultUtil; +import org.apache.asterix.common.config.AbstractAsterixProperties; import org.apache.asterix.runtime.util.AsterixClusterProperties; import org.json.JSONException; import org.json.JSONObject; @@ -40,7 +44,9 @@ PrintWriter responseWriter = response.getWriter(); try { JSONObject responseObject = AsterixClusterProperties.INSTANCE.getClusterStateDescription(); - responseWriter.write(responseObject.toString()); + Map<String, Object> allProperties = getAllClusterProperties(); + responseObject.put("config", allProperties); + responseWriter.write(responseObject.toString(4)); response.setStatus(HttpServletResponse.SC_OK); } catch (JSONException e) { ResultUtil.apiErrorHandler(responseWriter, e); @@ -48,4 +54,16 @@ } responseWriter.flush(); } + + protected Map<String, Object> getAllClusterProperties() { + Map<String, Object> allProperties = new HashMap<>(); + for (AbstractAsterixProperties properties : getPropertiesInstances()) { + allProperties.putAll(properties.getProperties()); + } + return allProperties; + } + + protected List<AbstractAsterixProperties> getPropertiesInstances() { + return AbstractAsterixProperties.getImplementations(); + } } diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractAsterixProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractAsterixProperties.java index e68676e..845483e 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractAsterixProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractAsterixProperties.java @@ -18,10 +18,49 @@ */ package org.apache.asterix.common.config; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + public abstract class AbstractAsterixProperties { + private static final Logger LOGGER = Logger.getLogger(AbstractAsterixProperties.class.getName()); + private static final List<AbstractAsterixProperties> IMPLS = Collections.synchronizedList(new ArrayList<>()); + protected final AsterixPropertiesAccessor accessor; public AbstractAsterixProperties(AsterixPropertiesAccessor accessor) { this.accessor = accessor; + IMPLS.add(this); + } + + public Map<String, Object> getProperties() { + Map<String, Object> properties = new HashMap<>(); + for (Method m : getClass().getMethods()) { + PropertyKey key = m.getAnnotation(PropertyKey.class); + if (key != null) { + try { + properties.put(key.value(), m.invoke(this)); + } catch (Exception e) { + LOGGER.log(Level.INFO, "Error accessing property: " + key.value(), e); + } + } + } + return properties; + } + + @Retention(RetentionPolicy.RUNTIME) + public @interface PropertyKey { + String value(); + } + + public static List<AbstractAsterixProperties> getImplementations() { + return Collections.unmodifiableList(IMPLS); } } diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixCompilerProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixCompilerProperties.java index 5bfb5f8..af5124b 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixCompilerProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixCompilerProperties.java @@ -18,18 +18,23 @@ */ package org.apache.asterix.common.config; +import org.apache.hyracks.util.StorageUtil; + +import static org.apache.hyracks.util.StorageUtil.StorageUnit.KILOBYTE; +import static org.apache.hyracks.util.StorageUtil.StorageUnit.MEGABYTE; + public class AsterixCompilerProperties extends AbstractAsterixProperties { private static final String COMPILER_SORTMEMORY_KEY = "compiler.sortmemory"; - private static final long COMPILER_SORTMEMORY_DEFAULT = (32 << 20); // 32MB + private static final long COMPILER_SORTMEMORY_DEFAULT = StorageUtil.getSizeInBytes(32, MEGABYTE); private static final String COMPILER_GROUPMEMORY_KEY = "compiler.groupmemory"; - private static final long COMPILER_GROUPMEMORY_DEFAULT = (32 << 20); // 32MB + private static final long COMPILER_GROUPMEMORY_DEFAULT = StorageUtil.getSizeInBytes(32, MEGABYTE); private static final String COMPILER_JOINMEMORY_KEY = "compiler.joinmemory"; - private static final long COMPILER_JOINMEMORY_DEFAULT = (32 << 20); // 32MB + private static final long COMPILER_JOINMEMORY_DEFAULT = StorageUtil.getSizeInBytes(32, MEGABYTE); private static final String COMPILER_FRAMESIZE_KEY = "compiler.framesize"; - private static int COMPILER_FRAMESIZE_DEFAULT = (32 << 10); // 32KB + private static final int COMPILER_FRAMESIZE_DEFAULT = StorageUtil.getSizeInBytes(32, KILOBYTE); private static final String COMPILER_PREGELIX_HOME = "compiler.pregelix.home"; private static final String COMPILER_PREGELIX_HOME_DEFAULT = "~/pregelix"; @@ -38,26 +43,31 @@ super(accessor); } + @PropertyKey(COMPILER_SORTMEMORY_KEY) public long getSortMemorySize() { return accessor.getProperty(COMPILER_SORTMEMORY_KEY, COMPILER_SORTMEMORY_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); } + @PropertyKey(COMPILER_JOINMEMORY_KEY) public long getJoinMemorySize() { return accessor.getProperty(COMPILER_JOINMEMORY_KEY, COMPILER_JOINMEMORY_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); } + @PropertyKey(COMPILER_GROUPMEMORY_KEY) public long getGroupMemorySize() { return accessor.getProperty(COMPILER_GROUPMEMORY_KEY, COMPILER_GROUPMEMORY_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); } + @PropertyKey(COMPILER_FRAMESIZE_KEY) public int getFrameSize() { return accessor.getProperty(COMPILER_FRAMESIZE_KEY, COMPILER_FRAMESIZE_DEFAULT, PropertyInterpreters.getIntegerBytePropertyInterpreter()); } + @PropertyKey(COMPILER_PREGELIX_HOME) public String getPregelixHome() { return accessor.getProperty(COMPILER_PREGELIX_HOME, COMPILER_PREGELIX_HOME_DEFAULT, PropertyInterpreters.getStringPropertyInterpreter()); diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExternalProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExternalProperties.java index b2a43e3..1a9096d 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExternalProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixExternalProperties.java @@ -23,84 +23,94 @@ public class AsterixExternalProperties extends AbstractAsterixProperties { private static final String EXTERNAL_WEBPORT_KEY = "web.port"; - private static int EXTERNAL_WEBPORT_DEFAULT = 19001; + private static final int EXTERNAL_WEBPORT_DEFAULT = 19001; private static final String EXTERNAL_SECONDARY_WEBPORT_KEY = "web.secondary.port"; - private static int EXTERNAL_SECONDARY_WEBPORT_DEFAULT = 19005; + private static final int EXTERNAL_SECONDARY_WEBPORT_DEFAULT = 19005; private static final String QUERY_WEBPORT_KEY = "web.queryinterface.port"; private static final int QUERY_WEBPORT_DEFAULT = 19006; private static final String EXTERNAL_LOGLEVEL_KEY = "log.level"; - private static Level EXTERNAL_LOGLEVEL_DEFAULT = Level.WARNING; + private static final Level EXTERNAL_LOGLEVEL_DEFAULT = Level.WARNING; private static final String EXTERNAL_APISERVER_KEY = "api.port"; - private static int EXTERNAL_APISERVER_DEFAULT = 19002; + private static final int EXTERNAL_APISERVER_DEFAULT = 19002; private static final String EXTERNAL_FEEDSERVER_KEY = "feed.port"; - private static int EXTERNAL_FEEDSERVER_DEFAULT = 19003; + private static final int EXTERNAL_FEEDSERVER_DEFAULT = 19003; private static final String EXTERNAL_CC_JAVA_OPTS_KEY = "cc.java.opts"; - private static String EXTERNAL_CC_JAVA_OPTS_DEFAULT = "-Xmx1024m"; + private static final String EXTERNAL_CC_JAVA_OPTS_DEFAULT = "-Xmx1024m"; private static final String EXTERNAL_NC_JAVA_OPTS_KEY = "nc.java.opts"; - private static String EXTERNAL_NC_JAVA_OPTS_DEFAULT = "-Xmx1024m"; + private static final String EXTERNAL_NC_JAVA_OPTS_DEFAULT = "-Xmx1024m"; private static final String EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER = "max.wait.active.cluster"; - private static int EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER_DEFAULT = 60; + private static final int EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER_DEFAULT = 60; private static final String EXTERNAL_PLOT_ACTIVATE = "plot.activate"; - private static Boolean EXTERNAL_PLOT_ACTIVATE_DEFAULT = new Boolean(false); + private static final boolean EXTERNAL_PLOT_ACTIVATE_DEFAULT = false; public AsterixExternalProperties(AsterixPropertiesAccessor accessor) { super(accessor); } + @PropertyKey(EXTERNAL_WEBPORT_KEY) public int getWebInterfacePort() { return accessor.getProperty(EXTERNAL_WEBPORT_KEY, EXTERNAL_WEBPORT_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(EXTERNAL_SECONDARY_WEBPORT_KEY) public int getSecondaryWebInterfacePort() { return accessor.getProperty(EXTERNAL_SECONDARY_WEBPORT_KEY, EXTERNAL_SECONDARY_WEBPORT_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(QUERY_WEBPORT_KEY) public int getQueryWebInterfacePort() { return accessor.getProperty(QUERY_WEBPORT_KEY, QUERY_WEBPORT_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(EXTERNAL_APISERVER_KEY) public int getAPIServerPort() { return accessor.getProperty(EXTERNAL_APISERVER_KEY, EXTERNAL_APISERVER_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(EXTERNAL_FEEDSERVER_KEY) public int getFeedServerPort() { return accessor.getProperty(EXTERNAL_FEEDSERVER_KEY, EXTERNAL_FEEDSERVER_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(EXTERNAL_LOGLEVEL_KEY) public Level getLogLevel() { return accessor.getProperty(EXTERNAL_LOGLEVEL_KEY, EXTERNAL_LOGLEVEL_DEFAULT, PropertyInterpreters.getLevelPropertyInterpreter()); } + @PropertyKey(EXTERNAL_NC_JAVA_OPTS_KEY) public String getNCJavaParams() { return accessor.getProperty(EXTERNAL_NC_JAVA_OPTS_KEY, EXTERNAL_NC_JAVA_OPTS_DEFAULT, PropertyInterpreters.getStringPropertyInterpreter()); } + @PropertyKey(EXTERNAL_CC_JAVA_OPTS_KEY) public String getCCJavaParams() { return accessor.getProperty(EXTERNAL_CC_JAVA_OPTS_KEY, EXTERNAL_CC_JAVA_OPTS_DEFAULT, PropertyInterpreters.getStringPropertyInterpreter()); } + @PropertyKey(EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER) public int getMaxWaitClusterActive() { return accessor.getProperty(EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER, EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(EXTERNAL_PLOT_ACTIVATE) public Boolean getIsPlottingEnabled() { return accessor.getProperty(EXTERNAL_PLOT_ACTIVATE, EXTERNAL_PLOT_ACTIVATE_DEFAULT, PropertyInterpreters.getBooleanPropertyInterpreter()); diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixFeedProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixFeedProperties.java index 0f3951e..ff4d81e 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixFeedProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixFeedProperties.java @@ -18,19 +18,24 @@ */ package org.apache.asterix.common.config; +import org.apache.hyracks.util.StorageUtil; + +import static org.apache.hyracks.util.StorageUtil.StorageUnit.MEGABYTE; + public class AsterixFeedProperties extends AbstractAsterixProperties { private static final String FEED_CENTRAL_MANAGER_PORT_KEY = "feed.central.manager.port"; - private static final int FEED_CENTRAL_MANAGER_PORT_DEFAULT = 4500; // port at which the Central Feed Manager listens for control messages from local Feed Managers + private static final int FEED_CENTRAL_MANAGER_PORT_DEFAULT = 4500; private static final String FEED_MEMORY_GLOBALBUDGET_KEY = "feed.memory.global.budget"; - private static final long FEED_MEMORY_GLOBALBUDGET_DEFAULT = 67108864; // 64MB or 2048 frames (assuming 32768 as frame size) + private static final long FEED_MEMORY_GLOBALBUDGET_DEFAULT = StorageUtil.getSizeInBytes(64, MEGABYTE); + // i.e. 2048 frames (assuming 32768 as frame size) private static final String FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_KEY = "feed.memory.available.wait.timeout"; private static final long FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_DEFAULT = 10; // 10 seconds private static final String FEED_PENDING_WORK_THRESHOLD_KEY = "feed.pending.work.threshold"; - private static final int FEED_PENDING_WORK_THRESHOLD_DEFAULT = 50; // maximum length of input queue before triggering corrective action + private static final int FEED_PENDING_WORK_THRESHOLD_DEFAULT = 50; private static final String FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_KEY = "feed.max.threshold.period"; private static final int FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_DEFAULT = 5; @@ -39,26 +44,37 @@ super(accessor); } + @PropertyKey(FEED_MEMORY_GLOBALBUDGET_KEY) public long getMemoryComponentGlobalBudget() { return accessor.getProperty(FEED_MEMORY_GLOBALBUDGET_KEY, FEED_MEMORY_GLOBALBUDGET_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); } + @PropertyKey(FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_KEY) public long getMemoryAvailableWaitTimeout() { return accessor.getProperty(FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_KEY, FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_DEFAULT, PropertyInterpreters.getLongPropertyInterpreter()); } + /** + * @return port at which the Central Feed Manager listens for control messages from local Feed Managers + */ + @PropertyKey(FEED_CENTRAL_MANAGER_PORT_KEY) public int getFeedCentralManagerPort() { return accessor.getProperty(FEED_CENTRAL_MANAGER_PORT_KEY, FEED_CENTRAL_MANAGER_PORT_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + /** + * @return maximum length of input queue before triggering corrective action + */ + @PropertyKey(FEED_PENDING_WORK_THRESHOLD_KEY) public int getPendingWorkThreshold() { return accessor.getProperty(FEED_PENDING_WORK_THRESHOLD_KEY, FEED_PENDING_WORK_THRESHOLD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_KEY) public int getMaxSuccessiveThresholdPeriod() { return accessor.getProperty(FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_KEY, FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java index eec4947..3774dc4 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java @@ -62,6 +62,7 @@ } } + @PropertyKey("replication.enabled") public boolean isReplicationEnabled() { if (cluster != null && cluster.getDataReplication() != null) { if (getReplicationFactor() == 1) { @@ -194,6 +195,7 @@ return replicaIds; } + @PropertyKey("replication.factor") public int getReplicationFactor() { if (cluster != null) { if (cluster.getDataReplication() == null || cluster.getDataReplication().getReplicationFactor() == null) { @@ -204,6 +206,7 @@ return REPLICATION_FACTOR_DEFAULT; } + @PropertyKey("replication.timeout") public int getReplicationTimeOut() { if (cluster != null) { return cluster.getDataReplication().getReplicationTimeOut().intValue(); @@ -254,20 +257,24 @@ return clientReplicas; } + @PropertyKey("replication.max.remote.recovery.attempts") public int getMaxRemoteRecoveryAttempts() { return MAX_REMOTE_RECOVERY_ATTEMPTS; } + @PropertyKey(REPLICATION_LOG_BUFFER_PAGE_SIZE_KEY) public int getLogBufferPageSize() { return accessor.getProperty(REPLICATION_LOG_BUFFER_PAGE_SIZE_KEY, REPLICATION_LOG_BUFFER_PAGE_SIZE_DEFAULT, PropertyInterpreters.getIntegerBytePropertyInterpreter()); } + @PropertyKey(REPLICATION_LOG_BUFFER_NUM_PAGES_KEY) public int getLogBufferNumOfPages() { return accessor.getProperty(REPLICATION_LOG_BUFFER_NUM_PAGES_KEY, REPLICATION_LOG_BUFFER_NUM_PAGES_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(REPLICATION_LOG_BATCH_SIZE_KEY) public int getLogBatchSize() { return accessor.getProperty(REPLICATION_LOG_BATCH_SIZE_KEY, REPLICATION_LOG_BATCH_SIZE_DEFAULT, PropertyInterpreters.getIntegerBytePropertyInterpreter()); diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixStorageProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixStorageProperties.java index 5fdbc1c..daeb099 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixStorageProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixStorageProperties.java @@ -19,45 +19,53 @@ package org.apache.asterix.common.config; import org.apache.hyracks.storage.common.buffercache.IBufferCache; +import org.apache.hyracks.util.StorageUtil; + +import static org.apache.hyracks.util.StorageUtil.StorageUnit.KILOBYTE; +import static org.apache.hyracks.util.StorageUtil.StorageUnit.MEGABYTE; public class AsterixStorageProperties extends AbstractAsterixProperties { private static final String STORAGE_BUFFERCACHE_PAGESIZE_KEY = "storage.buffercache.pagesize"; - private static int STORAGE_BUFFERCACHE_PAGESIZE_DEFAULT = (128 << 10); // 128KB + private static final int STORAGE_BUFFERCACHE_PAGESIZE_DEFAULT = StorageUtil.getSizeInBytes(128, KILOBYTE); private static final String STORAGE_BUFFERCACHE_SIZE_KEY = "storage.buffercache.size"; - private static final long STORAGE_BUFFERCACHE_SIZE_DEFAULT = (512 << 20); // 512 MB + private static final long STORAGE_BUFFERCACHE_SIZE_DEFAULT = StorageUtil.getSizeInBytes(512, MEGABYTE); private static final String STORAGE_BUFFERCACHE_MAXOPENFILES_KEY = "storage.buffercache.maxopenfiles"; - private static int STORAGE_BUFFERCACHE_MAXOPENFILES_DEFAULT = Integer.MAX_VALUE; + private static final int STORAGE_BUFFERCACHE_MAXOPENFILES_DEFAULT = Integer.MAX_VALUE; private static final String STORAGE_MEMORYCOMPONENT_PAGESIZE_KEY = "storage.memorycomponent.pagesize"; - private static final int STORAGE_MEMORYCOMPONENT_PAGESIZE_DEFAULT = (128 << 10); // 128KB + private static final int STORAGE_MEMORYCOMPONENT_PAGESIZE_DEFAULT = StorageUtil.getSizeInBytes(128, KILOBYTE); private static final String STORAGE_MEMORYCOMPONENT_NUMPAGES_KEY = "storage.memorycomponent.numpages"; private static final int STORAGE_MEMORYCOMPONENT_NUMPAGES_DEFAULT = 256; // ... so 32MB components - private static final String STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_KEY = "storage.metadata.memorycomponent.numpages"; + private static final String STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_KEY = + "storage.metadata.memorycomponent.numpages"; private static final int STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_DEFAULT = 256; // ... so 32MB components private static final String STORAGE_MEMORYCOMPONENT_NUMCOMPONENTS_KEY = "storage.memorycomponent.numcomponents"; private static final int STORAGE_MEMORYCOMPONENT_NUMCOMPONENTS_DEFAULT = 2; // 2 components private static final String STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_KEY = "storage.memorycomponent.globalbudget"; - private static final long STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_DEFAULT = 536870912; // 512MB + private static final long STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_DEFAULT = StorageUtil.getSizeInBytes(512, MEGABYTE); - private static final String STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_KEY = "storage.lsm.bloomfilter.falsepositiverate"; - private static double STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_DEFAULT = 0.01; + private static final String STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_KEY = + "storage.lsm.bloomfilter.falsepositiverate"; + private static final double STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_DEFAULT = 0.01; public AsterixStorageProperties(AsterixPropertiesAccessor accessor) { super(accessor); } + @PropertyKey(STORAGE_BUFFERCACHE_PAGESIZE_KEY) public int getBufferCachePageSize() { return accessor.getProperty(STORAGE_BUFFERCACHE_PAGESIZE_KEY, STORAGE_BUFFERCACHE_PAGESIZE_DEFAULT, PropertyInterpreters.getIntegerBytePropertyInterpreter()); } + @PropertyKey(STORAGE_BUFFERCACHE_SIZE_KEY) public long getBufferCacheSize() { return accessor.getProperty(STORAGE_BUFFERCACHE_SIZE_KEY, STORAGE_BUFFERCACHE_SIZE_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); @@ -67,38 +75,44 @@ return (int) (getBufferCacheSize() / (getBufferCachePageSize() + IBufferCache.RESERVED_HEADER_BYTES)); } + @PropertyKey(STORAGE_BUFFERCACHE_MAXOPENFILES_KEY) public int getBufferCacheMaxOpenFiles() { return accessor.getProperty(STORAGE_BUFFERCACHE_MAXOPENFILES_KEY, STORAGE_BUFFERCACHE_MAXOPENFILES_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(STORAGE_MEMORYCOMPONENT_PAGESIZE_KEY) public int getMemoryComponentPageSize() { return accessor.getProperty(STORAGE_MEMORYCOMPONENT_PAGESIZE_KEY, STORAGE_MEMORYCOMPONENT_PAGESIZE_DEFAULT, PropertyInterpreters.getIntegerBytePropertyInterpreter()); } + @PropertyKey(STORAGE_MEMORYCOMPONENT_NUMPAGES_KEY) public int getMemoryComponentNumPages() { return accessor.getProperty(STORAGE_MEMORYCOMPONENT_NUMPAGES_KEY, STORAGE_MEMORYCOMPONENT_NUMPAGES_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_KEY) public int getMetadataMemoryComponentNumPages() { - return accessor - .getProperty(STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_KEY, + return accessor.getProperty(STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_KEY, STORAGE_METADATA_MEMORYCOMPONENT_NUMPAGES_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(STORAGE_MEMORYCOMPONENT_NUMCOMPONENTS_KEY) public int getMemoryComponentsNum() { return accessor.getProperty(STORAGE_MEMORYCOMPONENT_NUMCOMPONENTS_KEY, STORAGE_MEMORYCOMPONENT_NUMCOMPONENTS_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_KEY) public long getMemoryComponentGlobalBudget() { return accessor.getProperty(STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_KEY, STORAGE_MEMORYCOMPONENT_GLOBALBUDGET_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); } + @PropertyKey(STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_KEY) public double getBloomFilterFalsePositiveRate() { return accessor.getProperty(STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_KEY, STORAGE_LSM_BLOOMFILTER_FALSEPOSITIVERATE_DEFAULT, PropertyInterpreters.getDoublePropertyInterpreter()); diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixTransactionProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixTransactionProperties.java index 00bcdc9..afc9e4f 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixTransactionProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixTransactionProperties.java @@ -21,33 +21,35 @@ import java.util.Map; import org.apache.hyracks.util.StorageUtil; -import org.apache.hyracks.util.StorageUtil.StorageUnit; + +import static org.apache.hyracks.util.StorageUtil.StorageUnit.KILOBYTE; +import static org.apache.hyracks.util.StorageUtil.StorageUnit.MEGABYTE; public class AsterixTransactionProperties extends AbstractAsterixProperties { private static final String TXN_LOG_BUFFER_NUMPAGES_KEY = "txn.log.buffer.numpages"; - private static int TXN_LOG_BUFFER_NUMPAGES_DEFAULT = 8; + private static final int TXN_LOG_BUFFER_NUMPAGES_DEFAULT = 8; private static final String TXN_LOG_BUFFER_PAGESIZE_KEY = "txn.log.buffer.pagesize"; - private static final int TXN_LOG_BUFFER_PAGESIZE_DEFAULT = (128 << 10); // 128KB + private static final int TXN_LOG_BUFFER_PAGESIZE_DEFAULT = StorageUtil.getSizeInBytes(128, KILOBYTE); private static final String TXN_LOG_PARTITIONSIZE_KEY = "txn.log.partitionsize"; - private static final long TXN_LOG_PARTITIONSIZE_DEFAULT = StorageUtil.getSizeInBytes(256L, StorageUnit.MEGABYTE); + private static final long TXN_LOG_PARTITIONSIZE_DEFAULT = StorageUtil.getSizeInBytes(256L, MEGABYTE); private static final String TXN_LOG_CHECKPOINT_LSNTHRESHOLD_KEY = "txn.log.checkpoint.lsnthreshold"; - private static final int TXN_LOG_CHECKPOINT_LSNTHRESHOLD_DEFAULT = (64 << 20); // 64M + private static final int TXN_LOG_CHECKPOINT_LSNTHRESHOLD_DEFAULT = StorageUtil.getSizeInBytes(64, MEGABYTE); private static final String TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY = "txn.log.checkpoint.pollfrequency"; - private static int TXN_LOG_CHECKPOINT_POLLFREQUENCY_DEFAULT = 120; // 120s + private static final int TXN_LOG_CHECKPOINT_POLLFREQUENCY_DEFAULT = 120; // 120s private static final String TXN_LOG_CHECKPOINT_HISTORY_KEY = "txn.log.checkpoint.history"; - private static int TXN_LOG_CHECKPOINT_HISTORY_DEFAULT = 0; + private static final int TXN_LOG_CHECKPOINT_HISTORY_DEFAULT = 0; private static final String TXN_LOCK_ESCALATIONTHRESHOLD_KEY = "txn.lock.escalationthreshold"; - private static int TXN_LOCK_ESCALATIONTHRESHOLD_DEFAULT = 1000; + private static final int TXN_LOCK_ESCALATIONTHRESHOLD_DEFAULT = 1000; private static final String TXN_LOCK_SHRINKTIMER_KEY = "txn.lock.shrinktimer"; - private static int TXN_LOCK_SHRINKTIMER_DEFAULT = 5000; // 5s + private static final int TXN_LOCK_SHRINKTIMER_DEFAULT = 5000; // 5s private static final String TXN_LOCK_TIMEOUT_WAITTHRESHOLD_KEY = "txn.lock.timeout.waitthreshold"; private static final int TXN_LOCK_TIMEOUT_WAITTHRESHOLD_DEFAULT = 60000; // 60s @@ -59,8 +61,7 @@ private static final int TXN_COMMIT_PROFILER_REPORT_INTERVAL_DEFAULT = 5; // 5 seconds private static final String TXN_JOB_RECOVERY_MEMORY_SIZE_KEY = "txn.job.recovery.memorysize"; - private static final long TXN_JOB_RECOVERY_MEMORY_SIZE_DEFAULT = StorageUtil.getSizeInBytes(64L, - StorageUnit.MEGABYTE); + private static final long TXN_JOB_RECOVERY_MEMORY_SIZE_DEFAULT = StorageUtil.getSizeInBytes(64L, MEGABYTE); public AsterixTransactionProperties(AsterixPropertiesAccessor accessor) { super(accessor); @@ -74,61 +75,73 @@ return accessor.getTransactionLogDirs(); } + @PropertyKey(TXN_LOG_BUFFER_NUMPAGES_KEY) public int getLogBufferNumPages() { return accessor.getProperty(TXN_LOG_BUFFER_NUMPAGES_KEY, TXN_LOG_BUFFER_NUMPAGES_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOG_BUFFER_PAGESIZE_KEY) public int getLogBufferPageSize() { return accessor.getProperty(TXN_LOG_BUFFER_PAGESIZE_KEY, TXN_LOG_BUFFER_PAGESIZE_DEFAULT, PropertyInterpreters.getIntegerBytePropertyInterpreter()); } + @PropertyKey(TXN_LOG_PARTITIONSIZE_KEY) public long getLogPartitionSize() { return accessor.getProperty(TXN_LOG_PARTITIONSIZE_KEY, TXN_LOG_PARTITIONSIZE_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); } + @PropertyKey(TXN_LOG_CHECKPOINT_LSNTHRESHOLD_KEY) public int getCheckpointLSNThreshold() { return accessor.getProperty(TXN_LOG_CHECKPOINT_LSNTHRESHOLD_KEY, TXN_LOG_CHECKPOINT_LSNTHRESHOLD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY) public int getCheckpointPollFrequency() { return accessor.getProperty(TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY, TXN_LOG_CHECKPOINT_POLLFREQUENCY_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOG_CHECKPOINT_HISTORY_KEY) public int getCheckpointHistory() { return accessor.getProperty(TXN_LOG_CHECKPOINT_HISTORY_KEY, TXN_LOG_CHECKPOINT_HISTORY_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOCK_ESCALATIONTHRESHOLD_KEY) public int getEntityToDatasetLockEscalationThreshold() { return accessor.getProperty(TXN_LOCK_ESCALATIONTHRESHOLD_KEY, TXN_LOCK_ESCALATIONTHRESHOLD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOCK_SHRINKTIMER_KEY) public int getLockManagerShrinkTimer() { return accessor.getProperty(TXN_LOCK_SHRINKTIMER_KEY, TXN_LOCK_SHRINKTIMER_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOCK_TIMEOUT_WAITTHRESHOLD_KEY) public int getTimeoutWaitThreshold() { return accessor.getProperty(TXN_LOCK_TIMEOUT_WAITTHRESHOLD_KEY, TXN_LOCK_TIMEOUT_WAITTHRESHOLD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_KEY) public int getTimeoutSweepThreshold() { return accessor.getProperty(TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_KEY, TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_COMMIT_PROFILER_REPORT_INTERVAL_KEY) public int getCommitProfilerReportInterval() { return accessor.getProperty(TXN_COMMIT_PROFILER_REPORT_INTERVAL_KEY, TXN_COMMIT_PROFILER_REPORT_INTERVAL_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); } + @PropertyKey(TXN_JOB_RECOVERY_MEMORY_SIZE_KEY) public long getJobRecoveryMemorySize() { return accessor.getProperty(TXN_JOB_RECOVERY_MEMORY_SIZE_KEY, TXN_JOB_RECOVERY_MEMORY_SIZE_DEFAULT, PropertyInterpreters.getLongBytePropertyInterpreter()); -- To view, visit https://asterix-gerrit.ics.uci.edu/1153 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I828d6a61afe615f7826079ede4b1d638bbd7ac5d Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow <mb...@apache.org>