use of org.teiid.client.util.ExceptionHolder in project teiid by teiid.
the class SocketServerInstanceImpl method receivedMessage.
private void receivedMessage(Object packet) {
// $NON-NLS-1$
log.log(Level.FINE, "reading packet");
if (packet instanceof Message) {
Message messagePacket = (Message) packet;
Serializable messageKey = messagePacket.getMessageKey();
ExceptionHolder holder = null;
if (messageKey instanceof ExceptionHolder) {
holder = (ExceptionHolder) messageKey;
messageKey = (Serializable) messagePacket.getContents();
if (log.isLoggable(Level.FINE)) {
// $NON-NLS-1$
log.log(Level.FINE, "read asynch message:" + messageKey);
}
if (messageKey == null) {
if (log.isLoggable(Level.FINE)) {
// $NON-NLS-1$
log.log(Level.FINE, "protocol error aborting all listeners");
}
for (ResultsReceiver<Object> listener : asynchronousListeners.values()) {
listener.exceptionOccurred(holder.getException());
}
asynchronousListeners.clear();
return;
}
}
if (log.isLoggable(Level.FINE)) {
// $NON-NLS-1$
log.log(Level.FINE, "read asynch message:" + messageKey);
}
ResultsReceiver<Object> listener = asynchronousListeners.remove(messageKey);
if (listener != null) {
if (holder != null) {
listener.exceptionOccurred(holder.getException());
} else {
listener.receiveResults(messagePacket.getContents());
}
}
} else {
// TODO: could ping back
if (log.isLoggable(Level.FINE)) {
// $NON-NLS-1$
log.log(Level.FINE, "packet ignored:" + packet);
}
}
}
use of org.teiid.client.util.ExceptionHolder in project teiid by teiid.
the class ResultsMessage method writeExternal.
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizeUtil.writeArray(out, columnNames);
ExternalizeUtil.writeArray(out, dataTypes);
// Results data
if (delayDeserialization) {
BatchSerializer.writeBatch(out, dataTypes, null, clientSerializationVersion);
} else {
BatchSerializer.writeBatch(out, dataTypes, results, clientSerializationVersion);
}
// Plan descriptions
out.writeObject(this.planDescription);
if (exception != null) {
out.writeObject(new ExceptionHolder(exception));
} else {
out.writeObject(exception);
}
if (delayDeserialization && results != null) {
serialize(true);
out.writeInt(serializationBuffer.getCount());
serializationBuffer.writeTo(out);
serializationBuffer = null;
}
if (this.warnings != null) {
out.writeObject(ExceptionHolder.toExceptionHolders(this.warnings));
} else {
out.writeObject(this.warnings);
}
out.writeInt(firstRow);
out.writeInt(lastRow);
out.writeInt(finalRow);
// Parameters
ExternalizeUtil.writeList(out, parameters);
out.writeObject(debugLog);
ExternalizeUtil.writeCollection(out, annotations);
out.writeBoolean(isUpdateResult);
if (isUpdateResult) {
out.writeInt(updateCount);
}
}
use of org.teiid.client.util.ExceptionHolder in project teiid by teiid.
the class ResultsMessage method readExternal.
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
columnNames = ExternalizeUtil.readStringArray(in);
dataTypes = ExternalizeUtil.readStringArray(in);
// Row data
results = BatchSerializer.readBatch(in, dataTypes);
// Plan Descriptions
planDescription = (PlanNode) in.readObject();
ExceptionHolder holder = (ExceptionHolder) in.readObject();
if (holder != null) {
this.exception = (TeiidException) holder.getException();
}
// delayed deserialization
if (results == null && this.exception == null) {
int length = in.readInt();
resultBytes = new byte[length];
in.readFully(resultBytes);
}
List<ExceptionHolder> holderList = (List<ExceptionHolder>) in.readObject();
if (holderList != null) {
this.warnings = ExceptionHolder.toThrowables(holderList);
}
firstRow = in.readInt();
lastRow = in.readInt();
finalRow = in.readInt();
// Parameters
parameters = ExternalizeUtil.readList(in, ParameterInfo.class);
debugLog = (String) in.readObject();
annotations = ExternalizeUtil.readList(in, Annotation.class);
isUpdateResult = in.readBoolean();
if (isUpdateResult) {
try {
updateCount = in.readInt();
} catch (OptionalDataException e) {
} catch (EOFException e) {
}
}
}
use of org.teiid.client.util.ExceptionHolder in project teiid by teiid.
the class SocketClientInstance method exceptionOccurred.
public void exceptionOccurred(Throwable t) {
// Object encoding may fail, so send a specific type of message to indicate there was a problem
if (objectSocket.isOpen() && !isClosedException(t)) {
if (workContext.getClientVersion().compareTo(Version.EIGHT_4) >= 0 && t instanceof FailedWriteException) {
FailedWriteException fwe = (FailedWriteException) t;
if (fwe.getObject() instanceof Message) {
Message m = (Message) fwe.getObject();
if (!(m.getMessageKey() instanceof ExceptionHolder)) {
Message exception = new Message();
exception.setContents(m.getMessageKey());
exception.setMessageKey(new ExceptionHolder(fwe.getCause()));
objectSocket.write(exception);
LogManager.log(getLevel(t), LogConstants.CTX_TRANSPORT, t, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40113));
return;
}
}
}
if (workContext.getClientVersion().compareTo(Version.EIGHT_6) >= 0) {
Message exception = new Message();
exception.setMessageKey(new ExceptionHolder(t));
objectSocket.write(exception);
LogManager.log(getLevel(t), LogConstants.CTX_TRANSPORT, t, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40113));
return;
}
}
int level = getLevel(t);
LogManager.log(level, LogConstants.CTX_TRANSPORT, LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL) || level < MessageLevel.WARNING ? t : null, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40114, t.getMessage()));
objectSocket.close();
}
Aggregations