use of com.alibaba.otter.canal.protocol.AdminPacket.Packet in project canal by alibaba.
the class SimpleAdminConnector method doInstanceAdmin.
private String doInstanceAdmin(String destination, String action) {
try {
writeWithHeader(Packet.newBuilder().setType(PacketType.INSTANCE).setBody(InstanceAdmin.newBuilder().setDestination(destination).setAction(action).build().toByteString()).build().toByteArray());
Packet p = Packet.parseFrom(readNextPacket());
Ack ack = Ack.parseFrom(p.getBody());
if (ack.getCode() > 0) {
throw new ServiceException("failed to subscribe with reason: " + ack.getMessage());
}
return ack.getMessage();
} catch (IOException e) {
throw new ServiceException(e);
}
}
Aggregations