public int getIntProperty( String name ) { return getIntValue( properties, name ); }
public int getIntProperty( String name ) { return getIntValue( properties, name ); }
public void init() throws Exception { SYSTEM_KEYSPACE = properties.getProperty( "cassandra.system.keyspace" ,"Usergrid"); STATIC_APPLICATION_KEYSPACE = properties.getProperty( "cassandra.application.keyspace","Usergrid_Applications" ); if ( consistencyLevelPolicy == null ) { consistencyLevelPolicy = new ConfigurableConsistencyLevel(); ( ( ConfigurableConsistencyLevel ) consistencyLevelPolicy ) .setDefaultReadConsistencyLevel( HConsistencyLevel.ONE ); } accessMap = new HashMap<String, String>( 2 ); accessMap.put( "username", properties.getProperty( "cassandra.username" ) ); accessMap.put( "password", properties.getProperty( "cassandra.password" ) ); systemKeyspace = HFactory.createKeyspace( getApplicationKeyspace() , cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE, accessMap ); final int flushSize = getIntValue( properties, "cassandra.mutation.flushsize", 2000 ); CountingMutator.MAX_SIZE = flushSize; }
/** Create the keyspace */ private void createKeySpace( String keyspace ) { logger.info( "Creating keyspace: {}", keyspace ); String strategy_class = getString( properties, "cassandra.keyspace.strategy", "org.apache.cassandra.locator.SimpleStrategy" ); logger.info( "Using strategy: {}", strategy_class ); int replication_factor = getIntValue( properties, "cassandra.keyspace.replication", 1 ); logger.info( "Using replication (may be overriden by strategy options): {}", replication_factor ); // try { ThriftKsDef ks_def = ( ThriftKsDef ) HFactory .createKeyspaceDefinition( keyspace, strategy_class, replication_factor, new ArrayList<ColumnFamilyDefinition>() ); @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, String> strategy_options = filter( ( Map ) properties, "cassandra.keyspace.strategy.options.", true ); if ( strategy_options.size() > 0 ) { logger.info( "Strategy options: {}", mapToFormattedJsonString( strategy_options ) ); ks_def.setStrategyOptions( strategy_options ); } cluster.addKeyspace( ks_def ); waitForCreation( keyspace ); logger.info( "Created keyspace {}", keyspace ); }
@Test public void testRemoveNamespaces() throws Exception { Map props = new HashMap(); props.put("blah.booleanProperty", "true"); props.put("blah.blah.doubleProperty", NumberFormat.getInstance().format(0.124)); props.put("blah.blah.Blah.intProperty", "14"); props.put("longProperty", "999999999"); props.put("3456.stringProperty", "string"); props = PropertiesUtils.removeNamespaces(props); assertTrue(getBooleanValue(props, "booleanProperty", false)); assertEquals(0.124, 0, getDoubleValue(props, "doubleProperty", 0)); assertEquals(14, getIntValue(props, "intProperty", 0)); assertEquals(999999999, 0, getLongValue(props, "longProperty", 0)); assertEquals("string", getString(props, "stringProperty", "")); }
/** * Loads {@link QuickAnalysisStrategy} from a {@link UserPreferences} * object. * * @param userPreferences * @return */ public static QuickAnalysisStrategy loadFromUserPreferences(final UserPreferences userPreferences) { final Map<String, String> properties = userPreferences.getAdditionalProperties(); final int columnsPerAnalyzer = MapUtils.getIntValue(properties, USER_PREFERENCES_NAMESPACE + ".columnsPerAnalyzer", 5); final boolean includeValueDistribution = MapUtils.getBooleanValue(properties, USER_PREFERENCES_NAMESPACE + ".includeValueDistribution", false); final boolean includePatternFinder = MapUtils.getBooleanValue(properties, USER_PREFERENCES_NAMESPACE + ".includePatternFinder", false); return new QuickAnalysisStrategy(columnsPerAnalyzer, includeValueDistribution, includePatternFinder); }
@Test public void testRemoveNamespaces() throws Exception { Map props = new HashMap(); props.put("blah.booleanProperty", "true"); props.put("blah.blah.doubleProperty", NumberFormat.getInstance().format(0.124)); props.put("blah.blah.Blah.intProperty", "14"); props.put("longProperty", "999999999"); props.put("3456.stringProperty", "string"); props = PropertiesUtils.removeNamespaces(props); assertTrue(getBooleanValue(props, "booleanProperty", false)); assertEquals(0.124, 0, getDoubleValue(props, "doubleProperty", 0)); assertEquals(14, getIntValue(props, "intProperty", 0)); assertEquals(999999999, 0, getLongValue(props, "longProperty", 0)); assertEquals("string", getString(props, "stringProperty", "")); }
distCpOptions.setLogPath(MoreMapUtils.getHadoopPath(copierOptions, LOG_PATH, distCpOptions.getLogPath())); int taskBandwidth = MapUtils.getIntValue(copierOptions, TASK_BANDWIDTH, distCpOptions.getMapBandwidth()); if (taskBandwidth <= 0) { throw new IllegalArgumentException("Parameter " + TASK_BANDWIDTH + " must be a positive integer."); int maxMaps = MapUtils.getIntValue(copierOptions, MAX_MAPS, distCpOptions.getMaxMaps()); if (maxMaps <= 0) { throw new IllegalArgumentException("Parameter " + MAX_MAPS + " must be a positive integer.");
distCpOptions.setLogPath(MoreMapUtils.getHadoopPath(copierOptions, LOG_PATH, distCpOptions.getLogPath())); int taskBandwidth = MapUtils.getIntValue(copierOptions, TASK_BANDWIDTH, distCpOptions.getMapBandwidth()); if (taskBandwidth <= 0) { throw new IllegalArgumentException("Parameter " + TASK_BANDWIDTH + " must be a positive integer."); int maxMaps = MapUtils.getIntValue(copierOptions, MAX_MAPS, distCpOptions.getMaxMaps()); if (maxMaps <= 0) { throw new IllegalArgumentException("Parameter " + MAX_MAPS + " must be a positive integer.");
int numberOfUploadWorkers = MapUtils.getIntValue(copierOptions, NUMBER_OF_WORKERS_PER_MAP, ConfigurationVariable.NUMBER_OF_UPLOAD_WORKERS.defaultIntValue()); if (numberOfUploadWorkers <= 0) { int maxMaps = MapUtils.getIntValue(copierOptions, MAX_MAPS, ConfigurationVariable.MAX_MAPS.defaultIntValue()); if (maxMaps <= 0) { throw new IllegalArgumentException("Parameter " + MAX_MAPS + " must be a positive number greater than zero");
int numberOfUploadWorkers = MapUtils.getIntValue(copierOptions, NUMBER_OF_WORKERS_PER_MAP, ConfigurationVariable.NUMBER_OF_UPLOAD_WORKERS.defaultIntValue()); if (numberOfUploadWorkers <= 0) { int maxMaps = MapUtils.getIntValue(copierOptions, MAX_MAPS, ConfigurationVariable.MAX_MAPS.defaultIntValue()); if (maxMaps <= 0) { throw new IllegalArgumentException("Parameter " + MAX_MAPS + " must be a positive number greater than zero");