use of org.apache.qpid.server.configuration.updater.Task in project qpid-broker-j by apache.
the class AbstractVirtualHost method importMessageStore.
@Override
public void importMessageStore(final String source) {
try {
final URL url = convertStringToURL(source);
try (InputStream input = url.openStream();
BufferedInputStream bufferedInputStream = new BufferedInputStream(input);
DataInputStream data = new DataInputStream(bufferedInputStream)) {
final MessageStoreSerializer serializer = MessageStoreSerializer.FACTORY.newInstance(data);
doSync(doOnConfigThread(new Task<ListenableFuture<Void>, IOException>() {
@Override
public ListenableFuture<Void> execute() throws IOException {
if (getState() != State.STOPPED) {
throw new IllegalArgumentException("The importMessageStore operation can only be called when the virtual host is stopped");
}
try {
_messageStore.openMessageStore(AbstractVirtualHost.this);
checkMessageStoreEmpty();
final Map<String, UUID> queueMap = new HashMap<>();
getDurableConfigurationStore().reload(new ConfiguredObjectRecordHandler() {
@Override
public void handle(final ConfiguredObjectRecord record) {
if (record.getType().equals(Queue.class.getSimpleName())) {
queueMap.put((String) record.getAttributes().get(ConfiguredObject.NAME), record.getId());
}
}
});
serializer.deserialize(queueMap, _messageStore, data);
} finally {
_messageStore.closeMessageStore();
}
return Futures.immediateFuture(null);
}
@Override
public String getObject() {
return AbstractVirtualHost.this.toString();
}
@Override
public String getAction() {
return "importMessageStore";
}
@Override
public String getArguments() {
if (url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equalsIgnoreCase("https") || url.getProtocol().equalsIgnoreCase("file")) {
return "source=" + source;
} else if (url.getProtocol().equalsIgnoreCase("data")) {
return "source=<data stream>";
} else {
return "source=<unknown source type>";
}
}
}));
}
} catch (IOException e) {
throw new IllegalConfigurationException("Cannot convert '" + source + "' to a readable resource", e);
}
}
use of org.apache.qpid.server.configuration.updater.Task in project qpid-broker-j by apache.
the class AbstractVirtualHost method purgeLinkRegistry.
@Override
public void purgeLinkRegistry(final String containerIdPatternString, final String role, final String linkNamePatternString) {
doSync(doOnConfigThread(new Task<ListenableFuture<Void>, IOException>() {
@Override
public ListenableFuture<Void> execute() throws IOException {
if (getState() != State.STOPPED) {
throw new IllegalArgumentException("The purgeLinkRegistry operation can only be called when the virtual host is stopped.");
}
Pattern containerIdPattern = Pattern.compile(containerIdPatternString);
Pattern linkNamePattern = Pattern.compile(linkNamePatternString);
_messageStore.openMessageStore(AbstractVirtualHost.this);
try {
_linkRegistry.open();
try {
if ("SENDER".equals(role) || "BOTH".equals(role)) {
_linkRegistry.purgeSendingLinks(containerIdPattern, linkNamePattern);
}
if ("RECEIVER".equals(role) || "BOTH".equals(role)) {
_linkRegistry.purgeReceivingLinks(containerIdPattern, linkNamePattern);
}
return Futures.immediateFuture(null);
} finally {
_linkRegistry.close();
}
} finally {
_messageStore.closeMessageStore();
}
}
@Override
public String getObject() {
return AbstractVirtualHost.this.toString();
}
@Override
public String getAction() {
return "purgeLinkRegistry";
}
@Override
public String getArguments() {
return String.format("containerIdPattern='%s',role='%s',linkNamePattern='%s'", containerIdPatternString, role, linkNamePatternString);
}
}));
}
Aggregations