use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class DistributedHerder method deleteConnectorConfig.
@Override
public void deleteConnectorConfig(final String connName, final Callback<Created<ConnectorInfo>> callback) {
addRequest(() -> {
log.trace("Handling connector config request {}", connName);
if (!isLeader()) {
callback.onCompletion(new NotLeaderException("Only the leader can delete connector configs.", leaderUrl()), null);
return null;
}
if (!configState.contains(connName)) {
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), null);
} else {
log.trace("Removing connector config {} {}", connName, configState.connectors());
configBackingStore.removeConnectorConfig(connName);
callback.onCompletion(null, new Created<>(false, null));
}
return null;
}, forwardErrorCallback(callback));
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class DistributedHerder method restartConnector.
@Override
public HerderRequest restartConnector(final long delayMs, final String connName, final Callback<Void> callback) {
return addRequest(delayMs, () -> {
if (checkRebalanceNeeded(callback))
return null;
if (!configState.connectors().contains(connName)) {
callback.onCompletion(new NotFoundException("Unknown connector: " + connName), null);
return null;
}
if (assignment.connectors().contains(connName)) {
try {
worker.stopAndAwaitConnector(connName);
startConnector(connName, callback);
} catch (Throwable t) {
callback.onCompletion(t, null);
}
} else if (isLeader()) {
callback.onCompletion(new NotAssignedException("Cannot restart connector since it is not assigned to this member", member.ownerUrl(connName)), null);
} else {
callback.onCompletion(new NotLeaderException("Only the leader can process restart requests.", leaderUrl()), null);
}
return null;
}, forwardErrorCallback(callback));
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class DistributedHerder method restartConnectorAndTasks.
@Override
public void restartConnectorAndTasks(RestartRequest request, Callback<ConnectorStateInfo> callback) {
final String connectorName = request.connectorName();
addRequest(() -> {
if (checkRebalanceNeeded(callback)) {
return null;
}
if (!configState.connectors().contains(request.connectorName())) {
callback.onCompletion(new NotFoundException("Unknown connector: " + connectorName), null);
return null;
}
if (isLeader()) {
// Write a restart request to the config backing store, to be executed asynchronously in tick()
configBackingStore.putRestartRequest(request);
// Compute and send the response that this was accepted
Optional<RestartPlan> plan = buildRestartPlan(request);
if (!plan.isPresent()) {
callback.onCompletion(new NotFoundException("Status for connector " + connectorName + " not found", null), null);
} else {
callback.onCompletion(null, plan.get().restartConnectorStateInfo());
}
} else {
callback.onCompletion(new NotLeaderException("Only the leader can process restart requests.", leaderUrl()), null);
}
return null;
}, forwardErrorCallback(callback));
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class DistributedHerder method connectorInfo.
@Override
public void connectorInfo(final String connName, final Callback<ConnectorInfo> callback) {
log.trace("Submitting connector info request {}", connName);
addRequest(() -> {
if (checkRebalanceNeeded(callback))
return null;
if (!configState.contains(connName)) {
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), null);
} else {
callback.onCompletion(null, connectorInfo(connName));
}
return null;
}, forwardErrorCallback(callback));
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class DistributedHerder method putTaskConfigs.
@Override
public void putTaskConfigs(final String connName, final List<Map<String, String>> configs, final Callback<Void> callback, InternalRequestSignature requestSignature) {
log.trace("Submitting put task configuration request {}", connName);
if (internalRequestValidationEnabled()) {
ConnectRestException requestValidationError = null;
if (requestSignature == null) {
requestValidationError = new BadRequestException("Internal request missing required signature");
} else if (!keySignatureVerificationAlgorithms.contains(requestSignature.keyAlgorithm())) {
requestValidationError = new BadRequestException(String.format("This worker does not support the '%s' key signing algorithm used by other workers. " + "This worker is currently configured to use: %s. " + "Check that all workers' configuration files permit the same set of signature algorithms, " + "and correct any misconfigured worker and restart it.", requestSignature.keyAlgorithm(), keySignatureVerificationAlgorithms));
} else {
if (!requestSignature.isValid(sessionKey)) {
requestValidationError = new ConnectRestException(Response.Status.FORBIDDEN, "Internal request contained invalid signature.");
}
}
if (requestValidationError != null) {
callback.onCompletion(requestValidationError, null);
return;
}
}
addRequest(() -> {
if (!isLeader())
callback.onCompletion(new NotLeaderException("Only the leader may write task configurations.", leaderUrl()), null);
else if (!configState.contains(connName))
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), null);
else {
configBackingStore.putTaskConfigs(connName, configs);
callback.onCompletion(null, null);
}
return null;
}, forwardErrorCallback(callback));
}
Aggregations