Search in sources :

Example 81 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project flink by apache.

the class FoldApplyProcessAllWindowFunction method open.

@Override
public void open(Configuration configuration) throws Exception {
    FunctionUtils.openFunction(this.windowFunction, configuration);
    if (serializedInitialValue == null) {
        throw new RuntimeException("No initial value was serialized for the fold " + "window function. Probably the setOutputType method was not called.");
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue);
    DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais);
    initialValue = accSerializer.deserialize(in);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper)

Example 82 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project flink by apache.

the class FoldApplyWindowFunction method open.

@Override
public void open(Configuration configuration) throws Exception {
    super.open(configuration);
    if (accSerializer == null) {
        throw new RuntimeException("No serializer set for the fold accumulator type. " + "Probably the setOutputType method was not called.");
    }
    if (serializedInitialValue == null) {
        throw new RuntimeException("No initial value was serialized for the fold " + "window function. Probably the setOutputType method was not called.");
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue);
    DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais);
    initialValue = accSerializer.deserialize(in);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper)

Example 83 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project hadoop by apache.

the class TestConfiguration method testInputStreamResource.

public void testInputStreamResource() throws Exception {
    StringWriter writer = new StringWriter();
    out = new BufferedWriter(writer);
    startConfig();
    declareProperty("prop", "A", "A");
    endConfig();
    InputStream in1 = new ByteArrayInputStream(writer.toString().getBytes());
    Configuration conf = new Configuration(false);
    conf.addResource(in1);
    assertEquals("A", conf.get("prop"));
    InputStream in2 = new ByteArrayInputStream(writer.toString().getBytes());
    conf.addResource(in2);
    assertEquals("A", conf.get("prop"));
}
Also used : StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BufferedWriter(java.io.BufferedWriter)

Example 84 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project hadoop by apache.

the class TestConfiguration method getActualConf.

private Configuration getActualConf(String xmlStr) {
    Configuration ac = new Configuration(false);
    InputStream in = new ByteArrayInputStream(xmlStr.getBytes());
    ac.addResource(in);
    return ac;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

Example 85 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project flink by apache.

the class BlobServerPutTest method testPutStreamSuccessful.

@Test
public void testPutStreamSuccessful() {
    BlobServer server = null;
    BlobClient client = null;
    try {
        Configuration config = new Configuration();
        server = new BlobServer(config);
        InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
        client = new BlobClient(serverAddress, config);
        byte[] data = new byte[2000000];
        rnd.nextBytes(data);
        // put content addressable (like libraries)
        {
            BlobKey key1 = client.put(new ByteArrayInputStream(data));
            assertNotNull(key1);
        }
        // put under job and name scope
        {
            JobID jid = new JobID();
            String stringKey = "my test key";
            client.put(jid, stringKey, new ByteArrayInputStream(data));
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    } finally {
        if (client != null) {
            try {
                client.close();
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
        if (server != null) {
            server.shutdown();
        }
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) ByteArrayInputStream(java.io.ByteArrayInputStream) InetSocketAddress(java.net.InetSocketAddress) JobID(org.apache.flink.api.common.JobID) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)6879 Test (org.junit.Test)2274 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1791 InputStream (java.io.InputStream)1531 IOException (java.io.IOException)1400 DataInputStream (java.io.DataInputStream)600 ObjectInputStream (java.io.ObjectInputStream)597 X509Certificate (java.security.cert.X509Certificate)397 CertificateFactory (java.security.cert.CertificateFactory)355 ObjectOutputStream (java.io.ObjectOutputStream)333 File (java.io.File)279 ArrayList (java.util.ArrayList)270 Certificate (java.security.cert.Certificate)234 HashMap (java.util.HashMap)212 DataOutputStream (java.io.DataOutputStream)200 FileInputStream (java.io.FileInputStream)182 InputStreamReader (java.io.InputStreamReader)180 Test (org.testng.annotations.Test)171 Document (org.w3c.dom.Document)143 Map (java.util.Map)138