Class FailedMutation
- All Implemented Interfaces:
FailedElement
FailureHandler<FailedMutation>.
Carries the RowMutationEntry the serializer produced rather than the original record:
the sink writer is stateless and retains only mutations, so by the time the service rejects one
the original record object no longer exists. When serialization itself failed, getEntry() and getRowKey() are null.
getPayloadBytes() is the serialized MutateRowsRequest.Entry — the row key and
every mutation of it — so a dead-letter consumer recovers the whole mutation with
MutateRowsRequest.Entry.parseFrom(bytes).
Instances are created by the sink and are not serializable.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the table asproject.instance.table.getCause()Returns the underlying failure, ornullwhen none is available.Returns the connector that produced the failure, as a lower-case identifier ("bigquery","bigtable","cloudtasks","pubsub","spanner") — stable, so dead-letter consumers can key on it.Returns the table the mutation was routed to.com.google.cloud.bigtable.data.v2.models.RowMutationEntrygetEntry()Returns the mutation the serializer produced, ornullwhen the record could not be serialized in the first place.Returns the failure description.com.google.protobuf.ByteStringReturns the serialized mutation — row key and every mutation of it — ornullwhen serialization itself failed.com.google.protobuf.ByteStringReturns the row key the mutation applies to, ornullwhen the record could not be serialized.static FailedMutationof(TableDestination destination, com.google.cloud.bigtable.data.v2.models.RowMutationEntry entry, String errorMessage, Throwable cause) Creates a failed mutation.toString()Renders the failure as its siblings do: the destination, the size of the failed payload, and the message.
-
Method Details
-
of
public static FailedMutation of(TableDestination destination, @Nullable com.google.cloud.bigtable.data.v2.models.RowMutationEntry entry, String errorMessage, @Nullable Throwable cause) Creates a failed mutation. Intended for the sink implementation (and tests of custom handlers).- Parameters:
destination- the table the mutation was routed toentry- the mutation, ornullwhen serialization itself failederrorMessage- the failure descriptioncause- the underlying failure, ornull- Returns:
- the failed mutation
-
getDestination
Returns the table the mutation was routed to. -
getEntry
@Nullable public com.google.cloud.bigtable.data.v2.models.RowMutationEntry getEntry()Returns the mutation the serializer produced, ornullwhen the record could not be serialized in the first place. -
getRowKey
@Nullable public com.google.protobuf.ByteString getRowKey()Returns the row key the mutation applies to, ornullwhen the record could not be serialized. -
getConnector
Description copied from interface:FailedElementReturns the connector that produced the failure, as a lower-case identifier ("bigquery","bigtable","cloudtasks","pubsub","spanner") — stable, so dead-letter consumers can key on it.- Specified by:
getConnectorin interfaceFailedElement
-
describeDestination
Returns the table asproject.instance.table.- Specified by:
describeDestinationin interfaceFailedElement
-
getPayloadBytes
@Nullable public com.google.protobuf.ByteString getPayloadBytes()Returns the serialized mutation — row key and every mutation of it — ornullwhen serialization itself failed.- Specified by:
getPayloadBytesin interfaceFailedElement
-
getErrorMessage
Description copied from interface:FailedElementReturns the failure description. It is always present, even whenFailedElement.getCause()isnull, and it is the detail thatFailureHandler.failJob()raises andFailureHandler.logAndDrop()logs.- Specified by:
getErrorMessagein interfaceFailedElement
-
getCause
Description copied from interface:FailedElementReturns the underlying failure, ornullwhen none is available.- Specified by:
getCausein interfaceFailedElement
-
toString
Renders the failure as its siblings do: the destination, the size of the failed payload, and the message.It used to render the row key with
toStringUtf8(), which was the worst of both. A row key is arbitrary bytes, so decoding invalid UTF-8 substituted U+FFFD rather than failing —0xFEand0xFFboth arrived as one replacement character — while a key that was valid UTF-8 went into the line exactly. It neither identified the row nor kept it out of a log.What replaces it is the shape
FailedTask,FailedRowandFailedMessageshare, and it is the whole payload each of them measures rather than one field of it: the mutation's size is what an operator asks after anINVALID_ARGUMENTon a batch, and a row key's length answers that only for the part of it the key happens to be. Spanner'sFailedMutationcarries no key either.Not printing the key is deliberate and is not the rule an exception message follows. A message has one chance to name the offending row and no accessors, which is why the table layer's decode-failure guards and its empty-mutation refusal do carry an escaped key — a payload format's own failure carries whatever that format wrote. This type is handed to a
FailureHandlera user writes, and hasgetRowKey()for a handler that wants the row.This bounds the rendering and not the object. When serialization itself failed,
getRowKey()isnull— there is no entry to read it from — sogetCause()is the only place the row can be named. Whether it is named is that message's business and not this type's: the table sink's empty-mutation refusal carries the row key escaped, since a message is the one place that must name it, so a handler logging that cause publishes it — while its other refusals name none, and a cause here is just as likely to be whatever a user's ownBigtableSerializationSchemathrew. So this is neither a hole to close here nor a guarantee to lean on.
-