Search in sources :

Example 1 with CacheObjectBinaryProcessorImpl

use of org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl in project ignite by apache.

the class IgniteKernal method createComponent.

/**
     * Creates optional component.
     *
     * @param cls Component interface.
     * @param ctx Kernal context.
     * @return Created component.
     * @throws IgniteCheckedException If failed to create component.
     */
private static <T extends GridComponent> T createComponent(Class<T> cls, GridKernalContext ctx) throws IgniteCheckedException {
    assert cls.isInterface() : cls;
    T comp = ctx.plugins().createComponent(cls);
    if (comp != null)
        return comp;
    if (cls.equals(IgniteCacheObjectProcessor.class))
        return (T) new CacheObjectBinaryProcessorImpl(ctx);
    if (cls.equals(DiscoveryNodeValidationProcessor.class))
        return (T) new OsDiscoveryNodeValidationProcessor(ctx);
    Class<T> implCls = null;
    try {
        String clsName;
        // Handle special case for PlatformProcessor
        if (cls.equals(PlatformProcessor.class))
            clsName = ctx.config().getPlatformConfiguration() == null ? PlatformNoopProcessor.class.getName() : cls.getName() + "Impl";
        else
            clsName = componentClassName(cls);
        implCls = (Class<T>) Class.forName(clsName);
    } catch (ClassNotFoundException ignore) {
    // No-op.
    }
    if (implCls == null)
        throw new IgniteCheckedException("Failed to find component implementation: " + cls.getName());
    if (!cls.isAssignableFrom(implCls))
        throw new IgniteCheckedException("Component implementation does not implement component interface " + "[component=" + cls.getName() + ", implementation=" + implCls.getName() + ']');
    Constructor<T> constructor;
    try {
        constructor = implCls.getConstructor(GridKernalContext.class);
    } catch (NoSuchMethodException e) {
        throw new IgniteCheckedException("Component does not have expected constructor: " + implCls.getName(), e);
    }
    try {
        return constructor.newInstance(ctx);
    } catch (ReflectiveOperationException e) {
        throw new IgniteCheckedException("Failed to create component [component=" + cls.getName() + ", implementation=" + implCls.getName() + ']', e);
    }
}
Also used : PlatformNoopProcessor(org.apache.ignite.internal.processors.platform.PlatformNoopProcessor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IGNITE_REST_START_ON_CLIENT(org.apache.ignite.IgniteSystemProperties.IGNITE_REST_START_ON_CLIENT) ATTR_ACTIVE_ON_START(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_ACTIVE_ON_START) ATTR_LATE_AFFINITY_ASSIGNMENT(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LATE_AFFINITY_ASSIGNMENT) ATTR_JMX_PORT(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JMX_PORT) BEFORE_NODE_START(org.apache.ignite.lifecycle.LifecycleEventType.BEFORE_NODE_START) COPYRIGHT(org.apache.ignite.internal.IgniteVersionUtils.COPYRIGHT) LT(org.apache.ignite.internal.util.typedef.internal.LT) AFTER_NODE_START(org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_START) CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) OsDiscoveryNodeValidationProcessor(org.apache.ignite.internal.processors.nodevalidation.OsDiscoveryNodeValidationProcessor)

Example 2 with CacheObjectBinaryProcessorImpl

use of org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl in project ignite by apache.

the class GridBinaryMarshaller method threadLocalContext.

/**
     * @return Thread-bound context.
     */
public static BinaryContext threadLocalContext() {
    BinaryContext ctx = GridBinaryMarshaller.BINARY_CTX.get();
    if (ctx == null) {
        IgniteKernal ignite = IgnitionEx.localIgnite();
        IgniteCacheObjectProcessor proc = ignite.context().cacheObjects();
        if (proc instanceof CacheObjectBinaryProcessorImpl)
            return ((CacheObjectBinaryProcessorImpl) proc).binaryContext();
        else
            throw new IgniteIllegalStateException("Ignite instance must be started with " + BinaryMarshaller.class.getName() + " [name=" + ignite.name() + ']');
    }
    return ctx;
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) IgniteIllegalStateException(org.apache.ignite.IgniteIllegalStateException)

Example 3 with CacheObjectBinaryProcessorImpl

use of org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl in project ignite by apache.

the class GridCacheProcessor method withBinaryContext.

/**
     * @param c Closure.
     * @return Closure result.
     * @throws IgniteCheckedException If failed.
     */
private <T> T withBinaryContext(IgniteOutClosureX<T> c) throws IgniteCheckedException {
    IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
    BinaryContext oldCtx = null;
    if (objProc instanceof CacheObjectBinaryProcessorImpl) {
        GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl) objProc).marshaller();
        oldCtx = binMarsh == null ? null : binMarsh.pushContext();
    }
    try {
        return c.applyx();
    } finally {
        if (objProc instanceof CacheObjectBinaryProcessorImpl)
            GridBinaryMarshaller.popContext(oldCtx);
    }
}
Also used : CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext)

Example 4 with CacheObjectBinaryProcessorImpl

use of org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl in project ignite by apache.

the class BinaryEnumsSelfTest method testZeroTypeId.

/**
     * Check ability to resolve typeId from class name.
     *
     * @throws Exception If failed.
     */
public void testZeroTypeId() throws Exception {
    startUp(true);
    final BinaryContext ctx = ((CacheObjectBinaryProcessorImpl) ((IgniteEx) node1).context().cacheObjects()).binaryContext();
    final BinaryObject enumObj = new BinaryEnumObjectImpl(ctx, 0, EnumType.class.getName(), EnumType.ONE.ordinal());
    assert enumObj.type().isEnum();
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 5 with CacheObjectBinaryProcessorImpl

use of org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testSetBinaryObject.

/**
     *
     */
public void testSetBinaryObject() {
    // Prepare marshaller context.
    CacheObjectBinaryProcessorImpl proc = ((CacheObjectBinaryProcessorImpl) (grid(0)).context().cacheObjects());
    proc.marshal(new GridBinaryTestClasses.TestObjectContainer());
    proc.marshal(new GridBinaryTestClasses.TestObjectAllTypes());
    // Actual test.
    BinaryObject binaryObj = builder(GridBinaryTestClasses.TestObjectContainer.class.getName()).setField("foo", toBinary(new GridBinaryTestClasses.TestObjectAllTypes())).build();
    assertTrue(binaryObj.<GridBinaryTestClasses.TestObjectContainer>deserialize().foo instanceof GridBinaryTestClasses.TestObjectAllTypes);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Aggregations

CacheObjectBinaryProcessorImpl (org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl)6 BinaryObject (org.apache.ignite.binary.BinaryObject)3 IgniteCacheObjectProcessor (org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteIllegalStateException (org.apache.ignite.IgniteIllegalStateException)1 IGNITE_REST_START_ON_CLIENT (org.apache.ignite.IgniteSystemProperties.IGNITE_REST_START_ON_CLIENT)1 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1 ATTR_ACTIVE_ON_START (org.apache.ignite.internal.IgniteNodeAttributes.ATTR_ACTIVE_ON_START)1 ATTR_JMX_PORT (org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JMX_PORT)1 ATTR_LATE_AFFINITY_ASSIGNMENT (org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LATE_AFFINITY_ASSIGNMENT)1 COPYRIGHT (org.apache.ignite.internal.IgniteVersionUtils.COPYRIGHT)1 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)1 OsDiscoveryNodeValidationProcessor (org.apache.ignite.internal.processors.nodevalidation.OsDiscoveryNodeValidationProcessor)1 PlatformNoopProcessor (org.apache.ignite.internal.processors.platform.PlatformNoopProcessor)1 LT (org.apache.ignite.internal.util.typedef.internal.LT)1 AFTER_NODE_START (org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_START)1