Search in sources :

Example 76 with BinaryMarshaller

use of org.apache.ignite.internal.binary.BinaryMarshaller in project ignite by apache.

the class IgniteSqlRoutingTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(gridName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(IP_FINDER);
    c.setDiscoverySpi(disco);
    c.setMarshaller(new BinaryMarshaller());
    List<CacheConfiguration> ccfgs = new ArrayList<>();
    CacheConfiguration ccfg = buildCacheConfiguration(gridName);
    if (ccfg != null)
        ccfgs.add(ccfg);
    ccfgs.add(buildCacheConfiguration(CACHE_PERSON));
    ccfgs.add(buildCacheConfiguration(CACHE_CALL));
    c.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
    if (gridName.equals(NODE_CLIENT))
        c.setClientMode(true);
    c.setCacheKeyConfiguration(new CacheKeyConfiguration(CallKey.class));
    return c;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) ArrayList(java.util.ArrayList) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 77 with BinaryMarshaller

use of org.apache.ignite.internal.binary.BinaryMarshaller in project ignite by apache.

the class AbstractH2CompareQueryTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(IP_FINDER);
    c.setDiscoverySpi(disco);
    c.setMarshaller(new BinaryMarshaller());
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 78 with BinaryMarshaller

use of org.apache.ignite.internal.binary.BinaryMarshaller in project ignite by apache.

the class JdbcResultSetSelfTest method testObject.

/**
 * @throws Exception If failed.
 */
public void testObject() throws Exception {
    final Ignite ignite = ignite(0);
    final boolean binaryMarshaller = ignite.configuration().getMarshaller() instanceof BinaryMarshaller;
    final IgniteBinary binary = binaryMarshaller ? ignite.binary() : null;
    ResultSet rs = stmt.executeQuery(SQL);
    TestObjectField f1 = new TestObjectField(100, "AAAA");
    TestObjectField f2 = new TestObjectField(500, "BBBB");
    TestObject o = createObjectWithData(1);
    assertTrue(rs.next());
    assertEqualsToStringRepresentation(f1, binary, rs.getObject("f1"));
    assertEqualsToStringRepresentation(f1, binary, rs.getObject(16));
    assertEqualsToStringRepresentation(f2, binary, rs.getObject("f2"));
    assertEqualsToStringRepresentation(f2, binary, rs.getObject(17));
    assertNull(rs.getObject("f3"));
    assertTrue(rs.wasNull());
    assertNull(rs.getObject(18));
    assertTrue(rs.wasNull());
    assertEqualsToStringRepresentation(o, binary, rs.getObject("_val"));
    assertEqualsToStringRepresentation(o, binary, rs.getObject(19));
    assertFalse(rs.next());
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) ResultSet(java.sql.ResultSet) Ignite(org.apache.ignite.Ignite) IgniteBinary(org.apache.ignite.IgniteBinary)

Example 79 with BinaryMarshaller

use of org.apache.ignite.internal.binary.BinaryMarshaller in project ignite by apache.

the class JdbcMetadataSelfTest method testGetColumns.

/**
 * @throws Exception If failed.
 */
public void testGetColumns() throws Exception {
    final boolean primitivesInformationIsLostAfterStore = ignite(0).configuration().getMarshaller() instanceof BinaryMarshaller;
    try (Connection conn = DriverManager.getConnection(URL)) {
        DatabaseMetaData meta = conn.getMetaData();
        ResultSet rs = meta.getColumns("", "pers", "Person", "%");
        assert rs != null;
        Collection<String> names = new ArrayList<>(2);
        names.add("NAME");
        names.add("AGE");
        names.add("ORGID");
        int cnt = 0;
        while (rs.next()) {
            String name = rs.getString("COLUMN_NAME");
            assert names.remove(name);
            if ("NAME".equals(name)) {
                assert rs.getInt("DATA_TYPE") == VARCHAR;
                assert "VARCHAR".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 1;
            } else if ("AGE".equals(name) || "ORGID".equals(name)) {
                assert rs.getInt("DATA_TYPE") == INTEGER;
                assert "INTEGER".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == (primitivesInformationIsLostAfterStore ? 1 : 0);
            }
            if ("_KEY".equals(name)) {
                assert rs.getInt("DATA_TYPE") == OTHER;
                assert "OTHER".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 0;
            }
            if ("_VAL".equals(name)) {
                assert rs.getInt("DATA_TYPE") == OTHER;
                assert "OTHER".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 0;
            }
            cnt++;
        }
        assert names.isEmpty();
        assert cnt == 3;
        rs = meta.getColumns("", "org", "Organization", "%");
        assert rs != null;
        names.add("ID");
        names.add("NAME");
        cnt = 0;
        while (rs.next()) {
            String name = rs.getString("COLUMN_NAME");
            assert names.remove(name);
            if ("id".equals(name)) {
                assert rs.getInt("DATA_TYPE") == INTEGER;
                assert "INTEGER".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 0;
            } else if ("name".equals(name)) {
                assert rs.getInt("DATA_TYPE") == VARCHAR;
                assert "VARCHAR".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 1;
            }
            if ("_KEY".equals(name)) {
                assert rs.getInt("DATA_TYPE") == VARCHAR;
                assert "VARCHAR".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 0;
            }
            if ("_VAL".equals(name)) {
                assert rs.getInt("DATA_TYPE") == OTHER;
                assert "OTHER".equals(rs.getString("TYPE_NAME"));
                assert rs.getInt("NULLABLE") == 0;
            }
            cnt++;
        }
        assert names.isEmpty();
        assert cnt == 2;
    }
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 80 with BinaryMarshaller

use of org.apache.ignite.internal.binary.BinaryMarshaller in project ignite by apache.

the class JdbcResultSetSelfTest method testObject.

/**
 * @throws Exception If failed.
 */
public void testObject() throws Exception {
    final Ignite ignite = ignite(0);
    final boolean binaryMarshaller = ignite.configuration().getMarshaller() instanceof BinaryMarshaller;
    final IgniteBinary binary = binaryMarshaller ? ignite.binary() : null;
    ResultSet rs = stmt.executeQuery(SQL);
    TestObjectField f1 = new TestObjectField(100, "AAAA");
    TestObjectField f2 = new TestObjectField(500, "BBBB");
    TestObject o = createObjectWithData(1);
    assertTrue(rs.next());
    assertEqualsToStringRepresentation(f1, binary, rs.getObject("f1"));
    assertEqualsToStringRepresentation(f1, binary, rs.getObject(16));
    assertEqualsToStringRepresentation(f2, binary, rs.getObject("f2"));
    assertEqualsToStringRepresentation(f2, binary, rs.getObject(17));
    assertNull(rs.getObject("f3"));
    assertTrue(rs.wasNull());
    assertNull(rs.getObject(18));
    assertTrue(rs.wasNull());
    assertEqualsToStringRepresentation(o, binary, rs.getObject("_val"));
    assertEqualsToStringRepresentation(o, binary, rs.getObject(19));
    assertFalse(rs.next());
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Ignite(org.apache.ignite.Ignite) IgniteBinary(org.apache.ignite.IgniteBinary)

Aggregations

BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)93 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)61 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)34 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)22 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)14 Ignite (org.apache.ignite.Ignite)9 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)9 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)9 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)8 ArrayList (java.util.ArrayList)7 BinaryObject (org.apache.ignite.binary.BinaryObject)7 Marshaller (org.apache.ignite.marshaller.Marshaller)7 IgniteException (org.apache.ignite.IgniteException)6 NullLogger (org.apache.ignite.logger.NullLogger)6 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)6 HashMap (java.util.HashMap)5 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)5 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)5 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)4