Search in sources :

Example 61 with ObjectOutput

use of java.io.ObjectOutput in project ignite by apache.

the class HadoopSplitWrapperSelfTest method testSerialization.

/**
 * Tests serialization of wrapper and the wrapped native split.
 * @throws Exception If fails.
 */
public void testSerialization() throws Exception {
    FileSplit nativeSplit = new FileSplit(new Path("/path/to/file"), 100, 500, new String[] { "host1", "host2" });
    assertEquals("/path/to/file:100+500", nativeSplit.toString());
    HadoopSplitWrapper split = HadoopUtils.wrapSplit(10, nativeSplit, nativeSplit.getLocations());
    assertEquals("[host1, host2]", Arrays.toString(split.hosts()));
    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    ObjectOutput out = new ObjectOutputStream(buf);
    out.writeObject(split);
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray()));
    final HadoopSplitWrapper res = (HadoopSplitWrapper) in.readObject();
    assertEquals("/path/to/file:100+500", HadoopUtils.unwrapSplit(res).toString());
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            res.hosts();
            return null;
        }
    }, AssertionError.class, null);
}
Also used : Path(org.apache.hadoop.fs.Path) ObjectOutput(java.io.ObjectOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileSplit(org.apache.hadoop.mapreduce.lib.input.FileSplit) ObjectOutputStream(java.io.ObjectOutputStream) HadoopSplitWrapper(org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapper) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInput(java.io.ObjectInput) ObjectInputStream(java.io.ObjectInputStream)

Example 62 with ObjectOutput

use of java.io.ObjectOutput in project ignite by apache.

the class KerberosHadoopFileSystemFactorySelfTest method checkSerialization.

/**
 * Serializes the factory,
 *
 * @param fac The facory to check.
 * @throws Exception If failed.
 */
private void checkSerialization(KerberosHadoopFileSystemFactory fac) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutput oo = new ObjectOutputStream(baos);
    oo.writeObject(fac);
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    KerberosHadoopFileSystemFactory fac2 = (KerberosHadoopFileSystemFactory) in.readObject();
    assertEquals(fac.getUri(), fac2.getUri());
    Assert.assertArrayEquals(fac.getConfigPaths(), fac2.getConfigPaths());
    assertEquals(fac.getKeyTab(), fac2.getKeyTab());
    assertEquals(fac.getKeyTabPrincipal(), fac2.getKeyTabPrincipal());
    assertEquals(fac.getReloginInterval(), fac2.getReloginInterval());
}
Also used : ObjectOutput(java.io.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInput(java.io.ObjectInput) ObjectOutputStream(java.io.ObjectOutputStream) KerberosHadoopFileSystemFactory(org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactory) ObjectInputStream(java.io.ObjectInputStream)

Example 63 with ObjectOutput

use of java.io.ObjectOutput in project ignite by apache.

the class HadoopUtils method wrapSplit.

/**
 * Wraps native split.
 *
 * @param id Split ID.
 * @param split Split.
 * @param hosts Hosts.
 * @throws IOException If failed.
 */
public static HadoopSplitWrapper wrapSplit(int id, Object split, String[] hosts) throws IOException {
    ByteArrayOutputStream arr = new ByteArrayOutputStream();
    ObjectOutput out = new ObjectOutputStream(arr);
    assert split instanceof Writable;
    ((Writable) split).write(out);
    out.flush();
    return new HadoopSplitWrapper(id, split.getClass().getName(), arr.toByteArray(), hosts);
}
Also used : HadoopSplitWrapper(org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapper) ObjectOutput(java.io.ObjectOutput) Writable(org.apache.hadoop.io.Writable) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 64 with ObjectOutput

use of java.io.ObjectOutput in project jPOS by jpos.

the class ISOFieldPackagerTest method testPack.

@Test
public void testPack() throws Throwable {
    ObjectOutput out = new ObjectOutputStream(new ByteArrayOutputStream());
    new IF_NOP().pack(new ISOVField((ISOField) new IFA_LCHAR().createComponent(100), new ISOVError("testISOFieldPackagerDescription")), out);
}
Also used : ObjectOutput(java.io.ObjectOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Test(org.junit.Test)

Example 65 with ObjectOutput

use of java.io.ObjectOutput in project jPOS by jpos.

the class ISOMsg2Test method testWriteDirection.

@Test
public void testWriteDirection() throws Throwable {
    ISOMsg iSOMsg = new ISOMsg("testISOMsgMti");
    ObjectOutput out = new ObjectOutputStream(new ByteArrayOutputStream());
    iSOMsg.writeDirection(out);
// int actual = out.
}
Also used : ObjectOutput(java.io.ObjectOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Test(org.junit.Test)

Aggregations

ObjectOutput (java.io.ObjectOutput)77 ObjectOutputStream (java.io.ObjectOutputStream)47 ByteArrayOutputStream (java.io.ByteArrayOutputStream)46 IOException (java.io.IOException)33 ObjectInput (java.io.ObjectInput)25 Test (org.junit.Test)20 ObjectInputStream (java.io.ObjectInputStream)15 ByteArrayInputStream (java.io.ByteArrayInputStream)14 WorkingMemory (org.drools.core.WorkingMemory)13 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)12 Pattern (org.drools.core.rule.Pattern)12 Consequence (org.drools.core.spi.Consequence)12 KnowledgeHelper (org.drools.core.spi.KnowledgeHelper)12 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)8 Declaration (org.drools.core.rule.Declaration)8 IntrospectionException (java.beans.IntrospectionException)7 InvalidRuleException (org.drools.core.rule.InvalidRuleException)7 ConsequenceException (org.drools.core.spi.ConsequenceException)7 OutputStream (java.io.OutputStream)6 ClassObjectType (org.drools.core.base.ClassObjectType)6