*/
private synchronized EditAndCommitResponse pushConfigWithConflictingVersionRetries(ConfigSnapshotHolder configSnapshotHolder) throws NetconfDocumentedException {
ConflictingVersionException lastException;
- Stopwatch stopwatch = new Stopwatch();
+ Stopwatch stopwatch = Stopwatch.createUnstarted();
do {
String idForReporting = configSnapshotHolder.toString();
SortedSet<String> expectedCapabilities = checkNotNull(configSnapshotHolder.getCapabilities(),
}
private NetconfOperationService getOperationServiceWithRetries(Set<String> expectedCapabilities, String idForReporting) {
- Stopwatch stopwatch = new Stopwatch().start();
+ Stopwatch stopwatch = Stopwatch.createStarted();
NotEnoughCapabilitiesException lastException;
do {
try {
throw new IllegalStateException("Cannot parse " + configSnapshotHolder);
}
LOG.trace("Pushing last configuration to netconf: {}", configSnapshotHolder);
- Stopwatch stopwatch = new Stopwatch().start();
+ Stopwatch stopwatch = Stopwatch.createStarted();
NetconfMessage editConfigMessage = createEditConfigMessage(xmlToBePersisted);
Document editResponseMessage = sendRequestGetResponseCheckIsOK(editConfigMessage, operationService,
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
-import com.google.common.io.CharStreams;
-import com.google.common.io.InputSupplier;
+import com.google.common.io.ByteSource;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import javax.xml.parsers.ParserConfigurationException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
public static String fileToString(final String fileName) throws IOException {
try (InputStream resourceAsStream = XmlFileLoader.class.getClassLoader().getResourceAsStream(fileName)) {
Preconditions.checkNotNull(resourceAsStream);
-
- InputSupplier<? extends InputStream> supplier = new InputSupplier<InputStream>() {
+ return new ByteSource() {
@Override
- public InputStream getInput() throws IOException {
+ public InputStream openStream() {
return resourceAsStream;
}
- };
-
- InputSupplier<InputStreamReader> readerSupplier = CharStreams.newReaderSupplier(supplier, Charsets.UTF_8);
+ }.asCharSource(Charsets.UTF_8).read();
- return CharStreams.toString(readerSupplier);
}
}