List of usage examples for com.google.common.base Preconditions checkArgument
public static void checkArgument(boolean expression)
From source file:org.apache.kylin.engine.streaming.cli.MonitorCLI.java
public static void main(String[] args) { Preconditions.checkArgument(args[0].equals("monitor")); int i = 1;//from w w w . ja v a2 s. c om List<String> receivers = null; String host = null; String tableName = null; String authorization = null; String cubeName = null; String projectName = "default"; while (i < args.length) { String argName = args[i]; switch (argName) { case "-receivers": receivers = Lists.newArrayList(StringUtils.split(args[++i], ";")); break; case "-host": host = args[++i]; break; case "-tableName": tableName = args[++i]; break; case "-authorization": authorization = args[++i]; break; case "-cubeName": cubeName = args[++i]; break; case "-projectName": projectName = args[++i]; break; default: throw new RuntimeException("invalid argName:" + argName); } i++; } Preconditions.checkArgument(receivers != null && receivers.size() > 0); final StreamingMonitor streamingMonitor = new StreamingMonitor(); if (tableName != null) { logger.info(String.format("check query tableName:%s host:%s receivers:%s", tableName, host, StringUtils.join(receivers, ";"))); Preconditions.checkNotNull(host); Preconditions.checkNotNull(authorization); Preconditions.checkNotNull(tableName); streamingMonitor.checkCountAll(receivers, host, authorization, projectName, tableName); } if (cubeName != null) { logger.info(String.format("check cube cubeName:%s receivers:%s", cubeName, StringUtils.join(receivers, ";"))); streamingMonitor.checkCube(receivers, cubeName, host); } System.exit(0); }
From source file:org.guldenj.tools.BlockImporter.java
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException { System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]"); System.out.println(" blockStore is required unless type is Mem or MemFull"); System.out.println(" eg BlockImporter prod H2 /home/user/guldenj.h2store"); System.out.println(" Does full verification if the store supports it"); Preconditions.checkArgument(args.length == 2 || args.length == 3); NetworkParameters params;//from w ww . ja va 2s . c o m if (args[0].equals("test")) params = TestNet3Params.get(); else params = MainNetParams.get(); BlockStore store; if (args[1].equals("H2")) { Preconditions.checkArgument(args.length == 3); store = new H2FullPrunedBlockStore(params, args[2], 100); } else if (args[1].equals("MemFull")) { Preconditions.checkArgument(args.length == 2); store = new MemoryFullPrunedBlockStore(params, 100); } else if (args[1].equals("Mem")) { Preconditions.checkArgument(args.length == 2); store = new MemoryBlockStore(params); } else if (args[1].equals("SPV")) { Preconditions.checkArgument(args.length == 3); store = new SPVBlockStore(params, new File(args[2])); } else { System.err.println("Unknown store " + args[1]); return; } AbstractBlockChain chain = null; if (store instanceof FullPrunedBlockStore) chain = new FullPrunedBlockChain(params, (FullPrunedBlockStore) store); else chain = new BlockChain(params, store); BlockFileLoader loader = new BlockFileLoader(params, BlockFileLoader.getReferenceClientBlockFileList()); for (Block block : loader) chain.add(block); }
From source file:org.bitcoinj_extra.tools.BlockImporter.java
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException { System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]"); System.out.println(" blockStore is required unless type is Mem or MemFull"); System.out.println(" eg BlockImporter prod H2 /home/user/bitcoinj_extra.h2store"); System.out.println(" Does full verification if the store supports it"); Preconditions.checkArgument(args.length == 2 || args.length == 3); NetworkParameters params;//from w w w. jav a 2s. co m if (args[0].equals("test")) params = TestNet3Params.get(); else params = MainNetParams.get(); BlockStore store; if (args[1].equals("H2")) { Preconditions.checkArgument(args.length == 3); store = new H2FullPrunedBlockStore(params, args[2], 100); } else if (args[1].equals("MemFull")) { Preconditions.checkArgument(args.length == 2); store = new MemoryFullPrunedBlockStore(params, 100); } else if (args[1].equals("Mem")) { Preconditions.checkArgument(args.length == 2); store = new MemoryBlockStore(params); } else if (args[1].equals("SPV")) { Preconditions.checkArgument(args.length == 3); store = new SPVBlockStore(params, new File(args[2])); } else { System.err.println("Unknown store " + args[1]); return; } AbstractBlockChain chain = null; if (store instanceof FullPrunedBlockStore) chain = new FullPrunedBlockChain(params, (FullPrunedBlockStore) store); else chain = new BlockChain(params, store); BlockFileLoader loader = new BlockFileLoader(params, BlockFileLoader.getReferenceClientBlockFileList()); for (Block block : loader) chain.add(block); }
From source file:org.bitcoinj.tools.BlockImporter.java
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException { System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]"); System.out.println(" blockStore is required unless type is Mem or MemFull"); System.out.println(" eg BlockImporter prod H2 /home/user/bitcoinj.h2store"); System.out.println(" Does full verification if the store supports it"); Preconditions.checkArgument(args.length == 2 || args.length == 3); NetworkParameters params;/*from w w w. j a va 2 s . c o m*/ if (args[0].equals("test")) params = TestNet3Params.get(); else params = MainNetParams.get(); BlockStore store; if (args[1].equals("H2")) { Preconditions.checkArgument(args.length == 3); store = new H2FullPrunedBlockStore(params, args[2], 100); } else if (args[1].equals("MemFull")) { Preconditions.checkArgument(args.length == 2); store = new MemoryFullPrunedBlockStore(params, 100); } else if (args[1].equals("Mem")) { Preconditions.checkArgument(args.length == 2); store = new MemoryBlockStore(params); } else if (args[1].equals("SPV")) { Preconditions.checkArgument(args.length == 3); store = new SPVBlockStore(params, new File(args[2])); } else { System.err.println("Unknown store " + args[1]); return; } AbstractBlockChain chain = null; if (store instanceof FullPrunedBlockStore) chain = new FullPrunedBlockChain(params, (FullPrunedBlockStore) store); else chain = new BlockChain(params, store); BlockFileLoader loader = new BlockFileLoader(params, BlockFileLoader.getReferenceClientBlockFileList()); for (Block block : loader) chain.add(block); }
From source file:org.litecoinj.tools.BlockImporter.java
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException { System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]"); System.out.println(" blockStore is required unless type is Mem or MemFull"); System.out.println(" eg BlockImporter prod H2 /home/user/litecoinj.h2store"); System.out.println(" Does full verification if the store supports it"); Preconditions.checkArgument(args.length == 2 || args.length == 3); NetworkParameters params;//ww w. j av a 2 s. c om if (args[0].equals("test")) params = TestNet3Params.get(); else params = MainNetParams.get(); BlockStore store; if (args[1].equals("H2")) { Preconditions.checkArgument(args.length == 3); store = new H2FullPrunedBlockStore(params, args[2], 100); } else if (args[1].equals("MemFull")) { Preconditions.checkArgument(args.length == 2); store = new MemoryFullPrunedBlockStore(params, 100); } else if (args[1].equals("Mem")) { Preconditions.checkArgument(args.length == 2); store = new MemoryBlockStore(params); } else if (args[1].equals("SPV")) { Preconditions.checkArgument(args.length == 3); store = new SPVBlockStore(params, new File(args[2])); } else { System.err.println("Unknown store " + args[1]); return; } AbstractBlockChain chain = null; if (store instanceof FullPrunedBlockStore) chain = new FullPrunedBlockChain(params, (FullPrunedBlockStore) store); else chain = new BlockChain(params, store); BlockFileLoader loader = new BlockFileLoader(params, BlockFileLoader.getReferenceClientBlockFileList()); for (Block block : loader) chain.add(block); }
From source file:org.apache.kylin.engine.streaming.cli.StreamingCLI.java
public static void main(String[] args) { try {/*from w w w . jav a2s. c o m*/ Preconditions.checkArgument(args[0].equals("streaming")); Preconditions.checkArgument(args[1].equals("start")); int i = 2; BootstrapConfig bootstrapConfig = new BootstrapConfig(); while (i < args.length) { String argName = args[i]; switch (argName) { case "-start": bootstrapConfig.setStart(Long.parseLong(args[++i])); break; case "-end": bootstrapConfig.setEnd(Long.parseLong(args[++i])); break; case "-cube": bootstrapConfig.setCubeName(args[++i]); break; case "-fillGap": bootstrapConfig.setFillGap(Boolean.parseBoolean(args[++i])); break; case "-maxFillGapRange": bootstrapConfig.setMaxFillGapRange(Long.parseLong(args[++i])); break; default: logger.warn("ignore this arg:" + argName); } i++; } if (bootstrapConfig.isFillGap()) { final List<Pair<Long, Long>> gaps = StreamingMonitor.findGaps(bootstrapConfig.getCubeName()); logger.info("all gaps:" + StringUtils.join(gaps, ",")); for (Pair<Long, Long> gap : gaps) { List<Pair<Long, Long>> splitGaps = splitGap(gap, bootstrapConfig.getMaxFillGapRange()); for (Pair<Long, Long> splitGap : splitGaps) { logger.info("start filling the gap from " + splitGap.getFirst() + " to " + splitGap.getSecond()); startOneOffCubeStreaming(bootstrapConfig.getCubeName(), splitGap.getFirst(), splitGap.getSecond()); logger.info("finish filling the gap from " + splitGap.getFirst() + " to " + splitGap.getSecond()); } } } else { startOneOffCubeStreaming(bootstrapConfig.getCubeName(), bootstrapConfig.getStart(), bootstrapConfig.getEnd()); logger.info("streaming process finished, exit with 0"); System.exit(0); } } catch (Exception e) { printArgsError(args); logger.error("error start streaming", e); System.exit(-1); } }
From source file:com.doctor.base64.CommonsCodecBase64.java
public static void main(String[] args) { String plainText = "Base64??" + "??ASCII???" + "????Base64"; // ??/*from w w w . j av a2s .co m*/ String base64String = Base64.encodeBase64String(plainText.getBytes(StandardCharsets.UTF_8)); System.out.println(base64String); String plainTxt = new String(Base64.decodeBase64(base64String), StandardCharsets.UTF_8); Preconditions.checkArgument(plainTxt.equals(plainText)); // ?? base64String = new String(Base64.encodeBase64Chunked(plainText.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); plainTxt = new String(Base64.decodeBase64(base64String), StandardCharsets.UTF_8); Preconditions.checkArgument(plainTxt.equals(plainText)); }
From source file:com.cloudera.nav.sdk.examples.extraction.IncrementalExtraction.java
public static void main(String[] args) throws IOException { // handle arguments Preconditions.checkArgument(args.length >= 2); String configFilePath = args[0]; String markerWritePath = args[1]; String startMarker = args.length > 2 ? readFileArg(args[2]) : null; String endMarker = args.length > 3 ? readFileArg(args[3]) : null; NavApiCient client = NavigatorPlugin.fromConfigFile(configFilePath).getClient(); // Extract metadata MetadataExtractor extractor = new MetadataExtractor(client, null); MetadataResultSet rs = extractor.extractMetadata(startMarker, endMarker); // Save the marker to be used next time String nextMarker = rs.getMarker(); try (PrintWriter markerWriter = new PrintWriter(markerWritePath, "UTF-8")) { markerWriter.println(nextMarker); }/*from ww w .j a v a2 s. c o m*/ // Iterate through entities and relations and process them Iterator<Map<String, Object>> entitiesIt = rs.getEntities().iterator(); Integer totalEntities = 0; while (entitiesIt.hasNext()) { processNextResult(entitiesIt.next()); totalEntities++; } Iterator<Map<String, Object>> relationsIt = rs.getRelations().iterator(); Integer totalRelations = 0; while (relationsIt.hasNext()) { processNextResult(relationsIt.next()); totalRelations++; } System.out.println("Total number of entities: " + totalEntities); System.out.println("Total number of relations: " + totalRelations); System.out.println("Next marker: " + nextMarker); }
From source file:com.cloudera.nav.sdk.examples.extraction.FilteredExtraction.java
public static void main(String[] args) throws IOException { // handle arguments Preconditions.checkArgument(args.length >= 2); String configFilePath = args[0]; String markerPath = args[1];//from w w w . ja v a2 s. co m String marker = args.length > 2 ? IncrementalExtraction.readFileArg(args[2]) : null; NavApiCient client = NavigatorPlugin.fromConfigFile(configFilePath).getClient(); MetadataExtractor extractor = new MetadataExtractor(client, null); // Run filtered examples getHDFSEntities(client, extractor, marker); getHive(extractor, marker, "city_id"); getHiveOperations(extractor, marker); String nextMarker = getMRandYarn(extractor, marker); // Save the last marker try (PrintWriter writer = new PrintWriter(markerPath, "UTF-8")) { writer.println(nextMarker); } }
From source file:com.cloudera.navigator.navigator_partner.extraction.HiveMetadataExtraction.java
public static void main(String[] args) throws IOException { // handle arguments Preconditions.checkArgument(args.length >= 2); String configFilePath = args[0]; String markerPath = args[1];/*from w ww .j a v a 2 s. com*/ String marker = args.length > 2 ? HiveMetadataExtraction.readFileArg(args[2]) : null; NavigatorPlugin navPlugin = NavigatorPlugin.fromConfigFile(configFilePath); NavApiCient client = navPlugin.getClient(); MetadataExtractor extractor = new MetadataExtractor(client, null); addCustomTags(navPlugin, extractor, marker); // Run filtered examples getHive(extractor, marker, "salary"); }