List of usage examples for com.google.common.collect Maps newHashMap
public static <K, V> HashMap<K, V> newHashMap()
From source file:org.sakaiproject.nakamura.lite.soak.mongo.ContentCreateSoak.java
public static void main(String[] argv) throws ClientPoolException, StorageClientException, AccessDeniedException, ClassNotFoundException, IOException { int totalContent = 100000; int nthreads = 1; if (argv.length > 0) { nthreads = StorageClientUtils.getSetting(Integer.valueOf(argv[0]), nthreads); }//w w w .j a va 2s . c o m if (argv.length > 1) { totalContent = StorageClientUtils.getSetting(Integer.valueOf(argv[1]), totalContent); } ConfigurationImpl configuration = new ConfigurationImpl(); Map<String, Object> cm = Maps.newHashMap(); cm.put("sling:resourceType", "test/resourcetype"); cm.put("sakai:pooled-content-manager", new String[] { "a", "b" }); cm.put("sakai:type", "sdfsdaggdsfgsdgsd"); cm.put("sakai:marker", "marker-marker-marker"); Map<String, Object> properties = Maps.newHashMap(); properties.put("keyspace", "n"); properties.put("acl-column-family", "ac"); properties.put("authorizable-column-family", "au"); properties.put("content-column-family", "cn"); configuration.activate(properties); ContentCreateSoak contentCreateSoak = new ContentCreateSoak(totalContent, getClientPool(configuration), configuration, cm); contentCreateSoak.launchSoak(nthreads); }
From source file:org.apache.streams.elasticsearch.example.ElasticsearchDelete.java
public static void main(String[] args) { LOGGER.info(StreamsConfigurator.config.toString()); Config reindex = StreamsConfigurator.config.getConfig("reindex"); Config source = reindex.getConfig("source"); Config destination = reindex.getConfig("destination"); ElasticsearchReaderConfiguration elasticsearchSourceConfiguration = ElasticsearchConfigurator .detectReaderConfiguration(source); ElasticsearchPersistReader elasticsearchPersistReader = new ElasticsearchPersistReader( elasticsearchSourceConfiguration); ElasticsearchWriterConfiguration elasticsearchDestinationConfiguration = ElasticsearchConfigurator .detectWriterConfiguration(destination); ElasticsearchPersistWriter elasticsearchPersistWriter = new ElasticsearchPersistDeleter( elasticsearchDestinationConfiguration); Map<String, Object> streamConfig = Maps.newHashMap(); streamConfig.put(LocalStreamBuilder.TIMEOUT_KEY, 20 * 60 * 1000); StreamBuilder builder = new LocalStreamBuilder(1000, streamConfig); builder.newPerpetualStream(ElasticsearchPersistReader.STREAMS_ID, elasticsearchPersistReader); builder.addStreamsPersistWriter(ElasticsearchPersistWriter.STREAMS_ID, elasticsearchPersistWriter, 1, ElasticsearchPersistReader.STREAMS_ID); builder.start();/* w ww . ja va 2 s .c o m*/ }
From source file:rooms.Application.java
public static void main(String[] args) throws ValueException, ThingException, InterruptedException { AbstractApplicationContext context = new AnnotationConfigApplicationContext(RoomConfig.class); //AbstractApplicationContext context = new AnnotationConfigApplicationContext(RoomConfigMongo.class); // MongoOperations mo = (MongoOperations) context.getBean("mongoTemplate"); final ThingControl tc = (ThingControl) context.getBean("thingControl"); for (String s : context.getBeanDefinitionNames()) { System.out.println(s);//from w w w . j ava 2 s . c om } System.out.println("THINGSSSS"); for (Thing t : tc.findAllThings()) { System.out.println("THING: " + t); } // mo.dropCollection(Thing.class); // mo.dropCollection(Bridge.class); // mo.dropCollection(Light.class); List<Thing> t = tc.findThingsForType("bridge"); Bridge b = new Bridge("10.0.0.40"); Thing tb = tc.createThing("bridge", b); Light l = new Light(Group.GROUP_1, "white"); Thing tl = tc.createThing("bedroom_ceiling", l); Light l2 = new Light(Group.GROUP_2, "white"); Thing tl2 = tc.createThing("bedroom_bed", l2); Light l3 = new Light(Group.GROUP_3, "white"); Thing tl3 = tc.createThing("bedroom_desk", l3); tc.addChildThing(tb, tl); tc.addChildThing(tb, tl2); tc.addChildThing(tb, tl3); List<Thing<Bridge>> bridges = tc.findThingsForType(Bridge.class); Map<String, LightWhiteV2> lights = Maps.newHashMap(); for (Thing<Bridge> bridgeThing : bridges) { Bridge bridge = tc.getValue(bridgeThing); LimitlessLEDControllerV2 c = new LimitlessLEDControllerV2(b.getHost(), b.getPort()); List<Thing<Light>> lightThings = tc.getChildrenForType(Observable.just(bridgeThing), Light.class, true); for (Thing<Light> tempLight : lightThings) { Light ll = tc.getValue(tempLight); LightWhiteV2 white = new LightWhiteV2(tempLight.getKey(), c, ll.getLightGroup()); lights.put(white.getName(), white); System.out.println("LIGHT: " + white.getName()); } } // lights.get("bedroom_ceiling").setOn(true); lights.get("bedroom_bed").setOn(true); Thread.sleep(2000); // lights.get("bedroom_ceiling").setOn(false); lights.get("bedroom_bed").setOn(false); Thread.sleep(2000); }
From source file:dmh.kuebiko.Main.java
public static void main(final String[] args) { PropertyConfigurator.configure(Main.class.getClassLoader().getResource("log4j.properties")); Thread.setDefaultUncaughtExceptionHandler(new KuebikoUncaughtExceptionHandler()); try {/* w ww. j a v a 2 s . c om*/ // Special setup to support MacOS X menus. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Kuebiko"); // Use the default look and feel of the host system. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } loadSettings(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Map<String, String> daoParams = Maps.newHashMap(); daoParams.put(DaoParameter.CLASS_NAME.toString(), getSetting(Setting.DAO_CLASS)); daoParams.put(DaoParameter.DIRECTORY.toString(), getSetting(Setting.DATA_LOCATION)); NoteManager noteMngr; try { noteMngr = new NoteManager(NoteDaoFactory.get(daoParams)); } catch (Exception e) { System.err.printf("Invalid parameters [%s].%n", daoParams); System.err.println("Valid DAOs:"); for (OfficialDao officialDao : OfficialDao.values()) { System.err.println(officialDao); } throw new RuntimeException(e); } NoteStackFrame noteFrame = new NoteStackFrame(noteMngr); noteFrame.setVisible(true); } }); }
From source file:org.lisapark.octopus.util.json.ExcelSardineUtils.java
public static void main(String[] args) { Map<String, Integer> prodCellIndexMap = Maps.newHashMap(); prodCellIndexMap.put(SHOP, 0);// ww w . j av a 2s .c o m prodCellIndexMap.put(SHIFT, 0); prodCellIndexMap.put(MACHINE, 0); prodCellIndexMap.put(PRODUCT, 0); prodCellIndexMap.put(PRODUCT_TYPE, 0); prodCellIndexMap.put(MATERIAL_TYPE, 0); prodCellIndexMap.put(RAW_MATERIAL, 4); prodCellIndexMap.put(TOTAL_MATERIALS, 5); prodCellIndexMap.put(TOTAL_PRODUCTS, 6); Map<String, Integer> wrhCellIndexMap = Maps.newHashMap(); wrhCellIndexMap.put(WAREHOUSE, 1); wrhCellIndexMap.put(ITEM, 1); wrhCellIndexMap.put(ITEM_TYPE, 1); wrhCellIndexMap.put(BEGINING, 0); wrhCellIndexMap.put(INCOMING, 1); wrhCellIndexMap.put(OUTGOING, 2); wrhCellIndexMap.put(ENDING, 3); try { String excelFile = "http://173.72.110.131:8080/WebDavServer/iPlast/Warehouse/"; // Get all xml files Sardine sardine = SardineFactory.begin("", ""); List<DavResource> resources = sardine.getResources(excelFile); for (DavResource res : resources) { String url = res.getPath(); //getAbsoluteUrl(); if (res.isDirectory()) { continue; } else { Map<String, String> props = res.getCustomProps(); if (props.get(PROCESSED) == null) { InputStream isData = sardine.get(url); HSSFWorkbook book = new HSSFWorkbook(isData); int index = 0; int increament = 1; if (book.getNumberOfSheets() > index) { if (increament == 0) { // increament = PROD_OUTLINE_INCREAMENT; increament = WRH_OUTLINE_INCREAMENT; } Sheet sheet = book.getSheetAt(index); if (sheet == null) { continue; } // Iterate through the rows. int splitRowNumber = 0; if (sheet.getPaneInformation() != null && sheet.getPaneInformation().isFreezePane()) { splitRowNumber = sheet.getPaneInformation().getHorizontalSplitPosition(); } Map<String, Object> rowMap = Maps.newHashMap(); int start = 2; Row dateRow = sheet.getRow(8); int end = dateRow.getLastCellNum(); for (int dateShift = start; dateShift < end - 4; dateShift = dateShift + 4) { rowMap.put(DATE, formatDate(dateRow.getCell(dateShift).getStringCellValue())); System.out.println(dateRow.getCell(dateShift).getStringCellValue()); Sheet _sheet = book.getSheetAt(index); for (Iterator<Row> rowsIt = _sheet.rowIterator(); rowsIt.hasNext();) { Row row = rowsIt.next(); if (row.getPhysicalNumberOfCells() <= 0 || row.getRowNum() < splitRowNumber) { continue; } Cell cell = row.getCell(1); int indent = cell.getCellStyle().getIndention(); int absIndent = indent / increament; // if (processRowWrhSs(rowMap, row, wrhCellIndexMap, absIndent, dateShift)) { System.out.println(rowMap); } } } } props.put(PROCESSED, TRUE); sardine.setCustomProps(url, props, null); } else { System.out.println("Property PROCESSED: " + props.get(PROCESSED)); List<String> removeProps = new ArrayList<String>(1); removeProps.add(PROCESSED); sardine.setCustomProps(url, null, removeProps); } break; } } } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
From source file:org.sakaiproject.nakamura.lite.soak.derby.ContentCreateSoak.java
public static void main(String[] argv) throws ClientPoolException, StorageClientException, AccessDeniedException, ClassNotFoundException, IOException { int totalContent = 100000; int nthreads = 1; if (argv.length > 0) { nthreads = StorageClientUtils.getSetting(Integer.valueOf(argv[0]), nthreads); }/*from w w w .j ava2 s .c o m*/ if (argv.length > 1) { totalContent = StorageClientUtils.getSetting(Integer.valueOf(argv[1]), totalContent); } ConfigurationImpl configuration = new ConfigurationImpl(); Map<String, Object> cm = Maps.newHashMap(); cm.put("sling:resourceType", "test/resourcetype"); cm.put("sakai:pooled-content-manager", new String[] { "a", "b" }); cm.put("sakai:type", "sdfsdaggdsfgsdgsd"); cm.put("sakai:marker", "marker-marker-marker"); Map<String, Object> properties = Maps.newHashMap(); properties.put("keyspace", "n"); properties.put("acl-column-family", "ac"); properties.put("authorizable-column-family", "au"); properties.put("content-column-family", "cn"); configuration.activate(properties); ContentCreateSoak contentCreateSoak = new ContentCreateSoak(totalContent, DerbySetup.getClientPool(configuration, "jdbc:derby:target/soak/db;create=true"), configuration, cm); contentCreateSoak.launchSoak(nthreads); contentCreateSoak.shutdown(); }
From source file:org.sakaiproject.nakamura.lite.soak.mysql.CreateUsersAndGroupsWithMembersSoak.java
public static void main(String[] argv) throws ClientPoolException, StorageClientException, AccessDeniedException, ClassNotFoundException, IOException { int totalUsers = 1000; int totalGroups = 1000; int nthreads = 10; if (argv.length > 0) { nthreads = StorageClientUtils.getSetting(Integer.valueOf(argv[0]), nthreads); }/*from ww w .j av a 2 s . c om*/ if (argv.length > 1) { totalUsers = StorageClientUtils.getSetting(Integer.valueOf(argv[1]), totalUsers); } if (argv.length > 2) { totalGroups = StorageClientUtils.getSetting(Integer.valueOf(argv[2]), totalUsers); } ConfigurationImpl configuration = new ConfigurationImpl(); Map<String, Object> properties = Maps.newHashMap(); properties.put("keyspace", "n"); properties.put("acl-column-family", "ac"); properties.put("authorizable-column-family", "au"); properties.put("content-column-family", "cn"); configuration.activate(properties); CreateUsersAndGroupsWithMembersSoak createUsersAndGroupsSoak = new CreateUsersAndGroupsWithMembersSoak( totalUsers, totalGroups, MysqlSetup.getClientPool(configuration), configuration); createUsersAndGroupsSoak.launchSoak(nthreads); }
From source file:org.sakaiproject.nakamura.lite.soak.derby.CreateUsersAndGroupsWithMembersSoak.java
public static void main(String[] argv) throws ClientPoolException, StorageClientException, AccessDeniedException, ClassNotFoundException, IOException { int totalUsers = 1000; int totalGroups = 1000; int nthreads = 10; if (argv.length > 0) { nthreads = StorageClientUtils.getSetting(Integer.valueOf(argv[0]), nthreads); }//from w ww . j a va2s .c o m if (argv.length > 1) { totalUsers = StorageClientUtils.getSetting(Integer.valueOf(argv[1]), totalUsers); } if (argv.length > 2) { totalGroups = StorageClientUtils.getSetting(Integer.valueOf(argv[2]), totalUsers); } ConfigurationImpl configuration = new ConfigurationImpl(); Map<String, Object> properties = Maps.newHashMap(); properties.put("keyspace", "n"); properties.put("acl-column-family", "ac"); properties.put("authorizable-column-family", "au"); properties.put("content-column-family", "cn"); configuration.activate(properties); CreateUsersAndGroupsWithMembersSoak createUsersAndGroupsSoak = new CreateUsersAndGroupsWithMembersSoak( totalUsers, totalGroups, DerbySetup.getClientPool(configuration, "jdbc:derby:target/soak/db;create=true"), configuration); createUsersAndGroupsSoak.launchSoak(nthreads); }
From source file:org.sakaiproject.nakamura.lite.soak.mongo.CreateUsersAndGroupsWithMembersSoak.java
public static void main(String[] argv) throws ClientPoolException, StorageClientException, AccessDeniedException, ClassNotFoundException, IOException { int totalUsers = 1000; int totalGroups = 100; int nthreads = 10; if (argv.length > 0) { nthreads = StorageClientUtils.getSetting(Integer.valueOf(argv[0]), nthreads); }/* w w w.ja va 2 s . com*/ if (argv.length > 1) { totalUsers = StorageClientUtils.getSetting(Integer.valueOf(argv[1]), totalUsers); } if (argv.length > 2) { totalGroups = StorageClientUtils.getSetting(Integer.valueOf(argv[2]), totalUsers); } ConfigurationImpl configuration = new ConfigurationImpl(); Map<String, Object> properties = Maps.newHashMap(); properties.put("keyspace", "n"); properties.put("acl-column-family", "ac"); properties.put("authorizable-column-family", "au"); properties.put("content-column-family", "cn"); configuration.activate(properties); CreateUsersAndGroupsWithMembersSoak createUsersAndGroupsSoak = new CreateUsersAndGroupsWithMembersSoak( totalUsers, totalGroups, getClientPool(configuration), configuration); createUsersAndGroupsSoak.launchSoak(nthreads); }
From source file:org.sakaiproject.nakamura.lite.soak.hbase.CreateUsersAndGroupsWithMembersSoak.java
public static void main(String[] argv) throws ClientPoolException, StorageClientException, AccessDeniedException, ClassNotFoundException, IOException { int totalUsers = 1000; int totalGroups = 100; int nthreads = 10; if (argv.length > 0) { nthreads = StorageClientUtils.getSetting(Integer.valueOf(argv[0]), nthreads); }/*from ww w.ja v a 2 s .c o m*/ if (argv.length > 1) { totalUsers = StorageClientUtils.getSetting(Integer.valueOf(argv[1]), totalUsers); } if (argv.length > 2) { totalGroups = StorageClientUtils.getSetting(Integer.valueOf(argv[2]), totalUsers); } ConfigurationImpl configuration = new ConfigurationImpl(); Map<String, Object> properties = Maps.newHashMap(); properties.put("keyspace", "n"); properties.put("acl-column-family", "ac"); properties.put("authorizable-column-family", "au"); properties.put("content-column-family", "cn"); configuration.activate(properties); CreateUsersAndGroupsWithMembersSoak createUsersAndGroupsSoak = new CreateUsersAndGroupsWithMembersSoak( totalUsers, totalGroups, getConnectionPool(configuration), configuration); createUsersAndGroupsSoak.launchSoak(nthreads); }