org.apache.ignite.binary.BinaryObjectException Java Examples

The following examples show how to use org.apache.ignite.binary.BinaryObjectException. 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: JdbcMetaTablesResult.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(
    BinaryWriterExImpl writer,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.writeBinary(writer, protoCtx);

    if (F.isEmpty(meta))
        writer.writeInt(0);
    else {
        writer.writeInt(meta.size());

        for (JdbcTableMeta m : meta)
            m.writeBinary(writer, protoCtx);
    }
}
 
Example #2
Source File: BinaryEnumObjectImpl.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public String enumName() throws BinaryObjectException {
    BinaryMetadata metadata = ctx.metadata0(typeId);

    if (metadata == null)
        throw new BinaryObjectException("Failed to get metadata for enum [typeId=" +
            typeId + ", typeName='" + clsName + "', ordinal=" + ord + "]");

    String name = metadata.getEnumNameByOrdinal(ord);

    if (name == null)
        throw new BinaryObjectException("Unable to resolve enum constant name [typeId=" +
            typeId + ", typeName='" + metadata.typeName() + "', ordinal=" + ord + "]");

    return name;
}
 
Example #3
Source File: BinaryContext.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Override binary class descriptor.
 *
 * @param other Other descriptor.
 * @throws BinaryObjectException If failed.
 */
private void override(TypeDescriptor other) throws BinaryObjectException {
    assert clsName.equals(other.clsName);

    if (canOverride) {
        mapper = other.mapper;
        serializer = other.serializer;
        identity = other.identity;
        affKeyFieldName = other.affKeyFieldName;
        isEnum = other.isEnum;
        enumMap = other.enumMap;
        canOverride = other.canOverride;
    }
    else if (!other.canOverride)
        throw new BinaryObjectException("Duplicate explicit class definition in configuration: " + clsName);
}
 
Example #4
Source File: JdbcBatchExecuteRequest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(
    BinaryWriterExImpl writer,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.writeBinary(writer, protoCtx);

    writer.writeString(schemaName);

    if (!F.isEmpty(queries)) {
        writer.writeInt(queries.size());

        for (JdbcQuery q : queries)
            q.writeBinary(writer, protoCtx);

    }
    else
        writer.writeInt(0);

    if (protoCtx.isStreamingSupported())
        writer.writeBoolean(lastStreamBatch);

    if (protoCtx.isAutoCommitSupported())
        writer.writeBoolean(autoCommit);
}
 
Example #5
Source File: JdbcMetaParamsResult.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(
    BinaryWriterExImpl writer,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.writeBinary(writer, protoCtx);

    if (F.isEmpty(meta))
        writer.writeInt(0);
    else {
        writer.writeInt(meta.size());

        for (JdbcParameterMeta m : meta)
            m.writeBinary(writer, protoCtx);
    }
}
 
Example #6
Source File: BinaryTypeProxy.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Target type.
 */
private BinaryType target() {
    if (target == null) {
        synchronized (this) {
            if (target == null) {
                if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID && clsName != null)
                    typeId = ctx.typeId(clsName);

                target = ctx.metadata(typeId);

                if (target == null)
                    throw new BinaryObjectException("Failed to get binary type details [typeId=" + typeId + ']');
            }
        }
    }

    return target;
}
 
Example #7
Source File: IgfsDirectoryInfo.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
    BinaryRawReader in = reader.rawReader();

    readBinary(in);

    if (in.readBoolean()) {
        int listingSize = in.readInt();

        listing = new HashMap<>(listingSize);

        for (int i = 0; i < listingSize; i++) {
            String key = in.readString();

            IgfsListingEntry val = IgfsUtils.readListingEntry(in);

            listing.put(key, val);
        }
    }
}
 
Example #8
Source File: JdbcMetaParamsResult.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void readBinary(
    BinaryReaderExImpl reader,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.readBinary(reader, protoCtx);

    int size = reader.readInt();

    if (size == 0)
        meta = Collections.emptyList();
    else {
        meta = new ArrayList<>(size);

        for (int i = 0; i < size; ++i) {
            JdbcParameterMeta m = new JdbcParameterMeta();

            m.readBinary(reader, protoCtx);

            meta.add(m);
        }
    }
}
 
Example #9
Source File: PartitionResultMarshaler.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Writes partition node to provided writer.
 *
 * @param writer Binary object writer.
 * @param node Partition node to serialize.
 * @throws BinaryObjectException In case of error.
 */
private static void writeNode(BinaryWriterExImpl writer, PartitionNode node)
    throws BinaryObjectException {
    assert !(node instanceof PartitionAllNode);
    assert !(node instanceof PartitionNoneNode);

    if (node instanceof PartitionCompositeNode)
        writeCompositeNode(writer, (PartitionCompositeNode)node);
    else if (node instanceof PartitionConstantNode)
        writeConstantNode(writer, (PartitionConstantNode)node);
    else if (node instanceof PartitionGroupNode)
        writeGroupNode(writer, (PartitionGroupNode)node);
    else if (node instanceof PartitionParameterNode)
        writeParameterNode(writer, (PartitionParameterNode)node);
    else
        throw new IllegalArgumentException("Partition node type " + node.getClass() + " not supported.");
}
 
Example #10
Source File: JdbcMetaColumnsResult.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void readBinary(
    BinaryReaderExImpl reader,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.readBinary(reader, protoCtx);

    int size = reader.readInt();

    if (size == 0)
        meta = Collections.emptyList();
    else {
        meta = new ArrayList<>(size);

        for (int i = 0; i < size; ++i) {
            JdbcColumnMeta m = createMetaColumn();

            m.readBinary(reader, protoCtx);

            meta.add(m);
        }
    }
}
 
Example #11
Source File: GridBinaryMarshaller.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param in Input stream.
 * @param ldr Class loader.
 * @param hnds Handles.
 * @return Deserialized object.
 * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
 */
@Nullable public <T> T deserialize(BinaryInputStream in, @Nullable ClassLoader ldr,
    @Nullable BinaryReaderHandles hnds) throws BinaryObjectException {
    BinaryContext oldCtx = pushContext(ctx);

    try {
        return (T)new BinaryReaderExImpl(ctx, in, ldr, hnds, true).deserialize();
    }
    finally {
        popContext(oldCtx);
    }
}
 
Example #12
Source File: WebSessionEntity.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void readBinary(final BinaryReader reader) throws BinaryObjectException {
    final BinaryRawReader rawReader = reader.rawReader();

    id = rawReader.readString();
    createTime = rawReader.readLong();
    accessTime = rawReader.readLong();
    maxInactiveInterval = rawReader.readInt();
    attrs = rawReader.readMap();
}
 
Example #13
Source File: BinaryReaderExImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override @Nullable public BigDecimal[] readDecimalArray() throws BinaryObjectException {
    switch (checkFlag(DECIMAL_ARR)) {
        case NORMAL:
            return BinaryUtils.doReadDecimalArray(in);

        case HANDLE:
            return readHandleField();

        default:
            return null;
    }
}
 
Example #14
Source File: CacheObjectBinaryProcessorImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cluster binary metadata.
 * @throws BinaryObjectException on error.
 */
public Collection<BinaryMetadata> binaryMetadata() throws BinaryObjectException {
    return F.viewReadOnly(metadataLocCache.values(), new IgniteClosure<BinaryMetadataHolder, BinaryMetadata>() {
        @Override public BinaryMetadata apply(BinaryMetadataHolder metaHolder) {
            return metaHolder.metadata();
        }
    });
}
 
Example #15
Source File: BinaryClassDescriptor.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Instance.
 * @throws BinaryObjectException In case of error.
 */
private Object newInstance() throws BinaryObjectException {
    try {
        return ctor != null ? ctor.newInstance() : GridUnsafe.allocateInstance(cls);
    }
    catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
        throw new BinaryObjectException("Failed to instantiate instance: " + cls, e);
    }
}
 
Example #16
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
    BinaryRawReader rawReader = reader.rawReader();

    val0 = rawReader.readInt();
    val1 = rawReader.readInt();
}
 
Example #17
Source File: IgniteTopic.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeString(COLUMN_ID, getId());
    writer.writeString(COLUMN_NAMESPACE, name.getNamespace());
    writer.writeString(COLUMN_CODE, name.getCode());
    writer.writeShort(COLUMN_PARTITIONS, partitions);
    writer.writeByte(COLUMN_TYPE, type.code());
    if (null != priorityPartitions) {
        writer.writeString(COLUMN_PRIORITY_PARTITIONS, Arrays.toString(priorityPartitions.toArray()));
    }
}
 
Example #18
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
    val = reader.readDecimal("val");
    valArr = reader.readDecimalArray("valArr");

    BinaryRawReader rawReader = reader.rawReader();

    rawVal = rawReader.readDecimal();
    rawValArr = rawReader.readDecimalArray();
}
 
Example #19
Source File: IgniteConfig.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void readBinary(BinaryReader reader) throws BinaryObjectException {
    //this.id = reader.readString(COLUMN_ID);
    this.group = reader.readString(COLUMN_CFG_GROUP);
    this.key = reader.readString(COLUMN_CFG_KEY);
    this.value = reader.readString(COLUMN_CFG_VALUE);
}
 
Example #20
Source File: CacheOffheapBatchIndexingBaseTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", id);
    writer.writeInt("orgId", orgId);
    writer.writeString("firstName", firstName);
    writer.writeString("lastName", lastName);
    writer.writeDouble("salary", salary);
}
 
Example #21
Source File: WebSessionAttributeProcessor.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(final BinaryWriter writer) throws BinaryObjectException {
    final BinaryRawWriter rawWriter = writer.rawWriter();

    rawWriter.writeMap(updatesMap);
    rawWriter.writeLong(accessTime);
    rawWriter.writeBoolean(maxIntervalChanged);

    if (maxIntervalChanged)
        rawWriter.writeInt(maxInactiveInterval);
}
 
Example #22
Source File: JdbcQueryExecuteRequest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(
    BinaryWriterExImpl writer,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.writeBinary(writer, protoCtx);

    writer.writeString(schemaName);
    writer.writeInt(pageSize);
    writer.writeInt(maxRows);
    writer.writeString(sqlQry);

    writer.writeInt(args == null ? 0 : args.length);

    if (args != null) {
        for (Object arg : args)
            JdbcUtils.writeObject(writer, arg, protoCtx);
    }

    if (protoCtx.isAutoCommitSupported())
        writer.writeBoolean(autoCommit);

    writer.writeByte((byte)stmtType.ordinal());

    if (protoCtx.isAffinityAwarenessSupported())
        writer.writeBoolean(partResReq);
}
 
Example #23
Source File: BinaryReaderExImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param fieldName Field name.
 * @return Unmarshalled value.
 * @throws BinaryObjectException In case of error.
 */
@Nullable Object unmarshalField(String fieldName) throws BinaryObjectException {
    try {
        return findFieldByName(fieldName) ? BinaryUtils.unmarshal(in, ctx, ldr, this) : null;
    }
    catch (Exception ex) {
        throw wrapFieldException(fieldName, ex);
    }
}
 
Example #24
Source File: BinaryReaderExImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public int readInt(String fieldName) throws BinaryObjectException {
    try {
        return findFieldByName(fieldName) && checkFlagNoHandles(INT) == Flag.NORMAL ? in.readInt() : 0;
    }
    catch (Exception ex) {
        throw wrapFieldException(fieldName, ex);
    }
}
 
Example #25
Source File: TestCachingMetadataHandler.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void addMeta(int typeId, BinaryType meta, boolean failIfUnregistered)
    throws BinaryObjectException {
    BinaryType otherType = metas.put(typeId, meta);

    if (otherType != null)
        throw new IllegalStateException("Metadata replacement is not allowed in " +
            TestCachingMetadataHandler.class.getSimpleName() + '.');
}
 
Example #26
Source File: IgfsMetaFileReserveSpaceProcessor.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    BinaryRawWriter out = writer.rawWriter();

    out.writeLong(space);
    out.writeObject(affRange);
}
 
Example #27
Source File: CacheObjectBinaryProcessorImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Collection<BinaryType> metadata() throws BinaryObjectException {
    return F.viewReadOnly(metadataLocCache.values(), new IgniteClosure<BinaryMetadataHolder, BinaryType>() {
        @Override public BinaryType apply(BinaryMetadataHolder metaHolder) {
            return metaHolder.metadata().wrap(binaryCtx);
        }
    });
}
 
Example #28
Source File: JdbcQueryFetchResult.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(
    BinaryWriterExImpl writer,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.writeBinary(writer, protoCtx);

    writer.writeBoolean(last);

    JdbcUtils.writeItems(writer, items, protoCtx);
}
 
Example #29
Source File: IgniteBinaryImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Collection<BinaryType> types() throws BinaryObjectException {
    guard();

    try {
        return proc.metadata();
    }
    finally {
        unguard();
    }
}
 
Example #30
Source File: JdbcQueryCancelRequest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(
    BinaryWriterExImpl writer,
    JdbcProtocolContext protoCtx
) throws BinaryObjectException {
    super.writeBinary(writer, protoCtx);

    writer.writeLong(reqIdToCancel);
}