java.lang.InterruptedException Java Examples
The following examples show how to use
java.lang.InterruptedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatReqSeekBlockVersion1() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="reqseekversion1.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block requiring seek version 1"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 482, block.getLength(),"Random block requiring seek version 1 must have a size of 482 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in block requiring seek version 1"); reader.close(); }
Example #2
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatGzipCompressed() throws IOException, InterruptedException{ Configuration conf = new Configuration(defaultConf); Job job = Job.getInstance(conf); CompressionCodec gzip = new GzipCodec(); ReflectionUtils.setConf(gzip, conf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4comp.blk.gz"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for compressed block"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 936, transactCount,"Comrpessed block must have at least 936 transactions"); reader.close(); }
Example #3
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatBzip2Compressed() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); Job job = Job.getInstance(conf); CompressionCodec bzip2 = new BZip2Codec(); ReflectionUtils.setConf(bzip2, conf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4comp.blk.bz2"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for compressed block"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 998039, block.getLength(),"Compressed block must have a size of 998.039 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in compressed block"); reader.close(); }
Example #4
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatBzip2Compressed() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); Job job = Job.getInstance(conf); CompressionCodec bzip2 = new BZip2Codec(); ReflectionUtils.setConf(bzip2, conf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4comp.blk.bz2"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for compressed block"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 936, transactCount,"Compressed block must have at least 936 transactions"); reader.close(); }
Example #5
Source File: OccurrencesForNote.java From java-docs-samples with Apache License 2.0 | 6 votes |
public static int getOccurrencesForNote(String noteId, String projectId) throws IOException, InterruptedException { // String noteId = "my-note"; // String projectId = "my-project-id"; final NoteName noteName = NoteName.of(projectId, noteId); ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder() .setName(noteName.toString()) .build(); // Initialize client that will be used to send requests. After completing all of your requests, // call the "close" method on the client to safely clean up any remaining background resources. GrafeasClient client = ContainerAnalysisClient.create().getGrafeasClient(); int i = 0; for (Occurrence o : client.listNoteOccurrences(request).iterateAll()) { // Write custom code to process each Occurrence here System.out.println(o.getName()); i = i + 1; } return i; }
Example #6
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatGzipCompressed() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); Job job = Job.getInstance(conf); CompressionCodec gzip = new GzipCodec(); ReflectionUtils.setConf(gzip, conf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4comp.blk.gz"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for compressed block"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 998039, block.getLength(),"Compressed block must have a size of 998.039 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in compressed block"); reader.close(); }
Example #7
Source File: OccurrencesForImage.java From java-docs-samples with Apache License 2.0 | 6 votes |
public static int getOccurrencesForImage(String resourceUrl, String projectId) throws IOException, InterruptedException { // String resourceUrl = "https://gcr.io/project/image@sha256:123"; // String projectId = "my-project-id"; final String projectName = ProjectName.format(projectId); final String filterStr = String.format("resourceUrl=\"%s\"", resourceUrl); // Initialize client that will be used to send requests. After completing all of your requests, // call the "close" method on the client to safely clean up any remaining background resources. GrafeasClient client = ContainerAnalysisClient.create().getGrafeasClient(); int i = 0; for (Occurrence o : client.listOccurrences(projectName, filterStr).iterateAll()) { // Write custom code to process each Occurrence here System.out.println(o.getName()); i = i + 1; } return i; }
Example #8
Source File: Subscriptions.java From java-docs-samples with Apache License 2.0 | 6 votes |
public static int pubSub(String subId, long timeoutSeconds, String projectId) throws InterruptedException { // String subId = "my-occurrence-subscription"; // long timeoutSeconds = 20; // String projectId = "my-project-id"; Subscriber subscriber = null; MessageReceiverExample receiver = new MessageReceiverExample(); try { // Subscribe to the requested Pub/Sub channel ProjectSubscriptionName subName = ProjectSubscriptionName.of(projectId, subId); subscriber = Subscriber.newBuilder(subName, receiver).build(); subscriber.startAsync().awaitRunning(); // Sleep to listen for messages TimeUnit.SECONDS.sleep(timeoutSeconds); } finally { // Stop listening to the channel if (subscriber != null) { subscriber.stopAsync(); } } // Print and return the number of Pub/Sub messages received System.out.println(receiver.messageCount); return receiver.messageCount; }
Example #9
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatBlockVersion1ReqSeek() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="reqseekversion1.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 1 requiring seek"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 2, transactCount,"Block version 1 requiring seek must contain exactly two transactions"); reader.close(); }
Example #10
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatBlockVersion4() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 4"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 936, transactCount,"Block version 4 must contain exactly 936 transactions"); reader.close(); }
Example #11
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatBlockVersion3() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version3.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 3"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 1645, transactCount,"Block version 3 must contain exactly 1645 transactions"); reader.close(); }
Example #12
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatBlockVersion2() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version2.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 2"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 343, transactCount,"Block version 2 must contain exactly 343 transactions"); reader.close(); }
Example #13
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatBlockVersion1() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version1.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 1"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0),context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 2, transactCount,"Block version 1 must contain exactly two transactions"); reader.close(); }
Example #14
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinBlockInputFormatReqSeekBlockVersion1() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="reqseekversion1.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinBlockFileInputFormat format = new BitcoinBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block requiring seek version 1"); RecordReader<BytesWritable, BitcoinBlock> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BitcoinBlock block = new BitcoinBlock(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 2, block.getTransactions().size(),"Random block requiring seek version 1 must contain exactly two transactions"); assertFalse( reader.nextKeyValue(),"No further blocks in block requiring seek version 1"); reader.close(); }
Example #15
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatMultiBlock() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="multiblock.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for multi block"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 346, transactCount,"Multiblock must contain exactly 1+2+343=346 transactions"); reader.close(); }
Example #16
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatBlockVersion4() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 4"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 998039, block.getLength(),"Random block version 4 must have a size of 998.039 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 4"); reader.close(); }
Example #17
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatBlockVersion3() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version3.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 3"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 932199, block.getLength(),"Random block version 3 must have size of 932.199 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 3"); reader.close(); }
Example #18
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatBlockVersion2() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version2.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 2"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 191198, block.getLength(),"Random block version 2 must have size of 191.198 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 2"); reader.close(); }
Example #19
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatBlockVersion1() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version1.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 1"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 482, block.getLength(),"Random block version 1 must have size of 482 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 1"); reader.close(); }
Example #20
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinRawBlockInputFormatGenesisBlock() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="genesis.blk"; String fileNameGenesis=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameGenesis); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for genesis block"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable genesisKey = new BytesWritable(); BytesWritable genesisBlock = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for genesis block contains at least one block"); genesisKey=reader.getCurrentKey(); genesisBlock=reader.getCurrentValue(); assertEquals( 293, genesisBlock.getLength(),"Genesis Block must have size of 293"); assertFalse( reader.nextKeyValue(),"No further blocks in genesis Block"); reader.close(); }
Example #21
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinBlockInputFormatGenesisBlock() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="genesis.blk"; String fileNameGenesis=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameGenesis); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinBlockFileInputFormat format = new BitcoinBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for genesis block"); RecordReader<BytesWritable, BitcoinBlock> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable genesisKey = new BytesWritable(); BitcoinBlock genesisBlock = new BitcoinBlock(); assertTrue( reader.nextKeyValue(),"Input Split for genesis block contains at least one block"); genesisBlock=reader.getCurrentValue(); assertEquals( 1, genesisBlock.getTransactions().size(),"Genesis Block must contain exactly one transaction"); assertFalse( reader.nextKeyValue(),"No further blocks in genesis Block"); reader.close(); }
Example #22
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinBlockInputFormatBlockVersion1() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version1.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinBlockFileInputFormat format = new BitcoinBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 1"); RecordReader<BytesWritable, BitcoinBlock> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BitcoinBlock block = new BitcoinBlock(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 2, block.getTransactions().size(),"Random block version 1 must contain exactly two transactions"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 1"); reader.close(); }
Example #23
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinBlockInputFormatBlockVersion2() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version2.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinBlockFileInputFormat format = new BitcoinBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 2"); RecordReader<BytesWritable, BitcoinBlock> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BitcoinBlock block = new BitcoinBlock(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 343, block.getTransactions().size(),"Random block version 2 must contain exactly 343 transactions"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 2"); reader.close(); }
Example #24
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinBlockInputFormatBlockVersion3() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version3.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinBlockFileInputFormat format = new BitcoinBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1,splits.size(),"Only one split generated for block version 3"); RecordReader<BytesWritable, BitcoinBlock> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BitcoinBlock block = new BitcoinBlock(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 1645, block.getTransactions().size(),"Random block version 3 must contain exactly 1645 transactions"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 3"); reader.close(); }
Example #25
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinBlockInputFormatBlockVersion4() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="version4.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinBlockFileInputFormat format = new BitcoinBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for block version 4"); RecordReader<BytesWritable, BitcoinBlock> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BitcoinBlock block = new BitcoinBlock(); assertTrue( reader.nextKeyValue(),"Input Split for block version contains at least one block"); block=reader.getCurrentValue(); assertEquals( 936, block.getTransactions().size(),"Random block version 4 must contain exactly 936 transactions"); assertFalse( reader.nextKeyValue(),"No further blocks in block version 4"); reader.close(); }
Example #26
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 6 votes |
@Test public void readBitcoinTransactionInputFormatGenesisBlock() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="genesis.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinTransactionFileInputFormat format = new BitcoinTransactionFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for genesis block"); RecordReader<BytesWritable, BitcoinTransaction> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); int transactCount=0; while (reader.nextKeyValue()) { transactCount++; } assertEquals( 1, transactCount,"Genesis Block must contain exactly one transactions"); reader.close(); }
Example #27
Source File: GetNote.java From java-docs-samples with Apache License 2.0 | 5 votes |
public static Note getNote(String noteId, String projectId) throws IOException, InterruptedException { // String noteId = "my-note"; // String projectId = "my-project-id"; final NoteName noteName = NoteName.of(projectId, noteId); // Initialize client that will be used to send requests. After completing all of your requests, // call the "close" method on the client to safely clean up any remaining background resources. GrafeasClient client = ContainerAnalysisClient.create().getGrafeasClient(); Note n = client.getNote(noteName); System.out.println(n); return n; }
Example #28
Source File: EarlyTimeout.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void run() { try { startedSignal.countDown(); long start = System.nanoTime(); reference = queue.remove(TIMEOUT); actual = NANOSECONDS.toMillis(System.nanoTime() - start); } catch (InterruptedException ex) { throw new RuntimeException(ex); } }
Example #29
Source File: Subscriptions.java From java-docs-samples with Apache License 2.0 | 5 votes |
public static Subscription createOccurrenceSubscription(String subId, String projectId) throws IOException, StatusRuntimeException, InterruptedException { // This topic id will automatically receive messages when Occurrences are added or modified String topicId = "container-analysis-occurrences-v1"; ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); ProjectSubscriptionName subName = ProjectSubscriptionName.of(projectId, subId); SubscriptionAdminClient client = SubscriptionAdminClient.create(); PushConfig config = PushConfig.getDefaultInstance(); Subscription sub = client.createSubscription(subName, topicName, config, 0); return sub; }
Example #30
Source File: BitcoinFormatHadoopTest.java From hadoopcryptoledger with Apache License 2.0 | 5 votes |
@Test public void readBitcoinRawBlockInputFormatMultiBlock() throws IOException, InterruptedException { Configuration conf = new Configuration(defaultConf); ClassLoader classLoader = getClass().getClassLoader(); String fileName="multiblock.blk"; String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile(); Path file = new Path(fileNameBlock); Job job = Job.getInstance(conf); FileInputFormat.setInputPaths(job, file); BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat(); List<InputSplit> splits = format.getSplits(job); TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID()); assertEquals( 1, splits.size(),"Only one split generated for multiblock"); RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context); assertNotNull( reader,"Format returned null RecordReader"); reader.initialize(splits.get(0),context); BytesWritable key = new BytesWritable(); BytesWritable block = new BytesWritable(); assertTrue( reader.nextKeyValue(),"Input Split for multi block contains the genesis block"); block=reader.getCurrentValue(); assertEquals( 293, block.getLength(),"Genesis Block must have size of 293"); assertTrue( reader.nextKeyValue(),"Input Split for block version contains block version 1"); block=reader.getCurrentValue(); assertEquals( 482, block.getLength(),"Random block version 1 must have size of 482 bytes"); assertTrue( reader.nextKeyValue(),"Input Split for block version contains block version 2"); block=reader.getCurrentValue(); assertEquals( 191198, block.getLength(),"Random block version 2 must have size of 191.198 bytes"); assertFalse( reader.nextKeyValue(),"No further blocks in multi block"); reader.close(); }