[cleanup] use diamond operator
With Java 7, we can change `Set<Instance> = new HashSet<Instance>()` to `Set<Instance> = new HashSet<>()` Related to #52. (cherry picked from commit 0c709de) (cherry picked from commit 4f474f5)
This commit is contained in:
parent
d11a813bce
commit
0e81e351c2
|
@ -110,29 +110,24 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent<AzureCom
|
|||
if (socketFactory == null) {
|
||||
// Azure plugin is disabled
|
||||
logger.trace("azure plugin is disabled. Returning an empty list of nodes.");
|
||||
return new HashSet<Instance>();
|
||||
return new HashSet<>();
|
||||
} else {
|
||||
try {
|
||||
InputStream stream = getXML("/services/hostedservices/" + service_name + "?embed-detail=true");
|
||||
Set<Instance> instances = buildInstancesFromXml(stream, port_name);
|
||||
logger.trace("get instances from azure: {}", instances);
|
||||
|
||||
return instances;
|
||||
|
||||
} catch (ParserConfigurationException e) {
|
||||
logger.warn("can not parse XML response: {}", e.getMessage());
|
||||
return new HashSet<Instance>();
|
||||
} catch (XPathExpressionException e) {
|
||||
logger.warn("can not parse XML response: {}", e.getMessage());
|
||||
return new HashSet<Instance>();
|
||||
} catch (SAXException e) {
|
||||
logger.warn("can not parse XML response: {}", e.getMessage());
|
||||
return new HashSet<Instance>();
|
||||
} catch (Exception e) {
|
||||
logger.warn("can not get list of azure nodes: {}", e.getMessage());
|
||||
return new HashSet<Instance>();
|
||||
}
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
private static String extractValueFromPath(Node node, String path) throws XPathExpressionException {
|
||||
|
@ -142,7 +137,7 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent<AzureCom
|
|||
}
|
||||
|
||||
public static Set<Instance> buildInstancesFromXml(InputStream inputStream, String port_name) throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
|
||||
Set<Instance> instances = new HashSet<Instance>();
|
||||
Set<Instance> instances = new HashSet<>();
|
||||
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
|
|
|
@ -168,7 +168,6 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
|
|||
CloudBlobContainer blob_container = client.getContainerReference(container);
|
||||
if (blob_container.exists()) {
|
||||
logger.trace("blob found. removing.", container, blob);
|
||||
// TODO A REVOIR
|
||||
CloudBlockBlob azureBlob = blob_container.getBlockBlobReference(blob);
|
||||
azureBlob.delete();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class AzureComputeServiceSimpleMock extends AzureComputeServiceAbstractMo
|
|||
|
||||
@Override
|
||||
public Set<Instance> instances() {
|
||||
Set<Instance> instances = new HashSet<Instance>();
|
||||
Set<Instance> instances = new HashSet<>();
|
||||
Instance azureHost = new Instance();
|
||||
azureHost.setPrivateIp("127.0.0.1");
|
||||
instances.add(azureHost);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class AzureComputeServiceTwoNodesMock extends AzureComputeServiceAbstract
|
|||
|
||||
@Override
|
||||
public Set<Instance> instances() {
|
||||
Set<Instance> instances = new HashSet<Instance>();
|
||||
Set<Instance> instances = new HashSet<>();
|
||||
Instance azureHost = new Instance();
|
||||
azureHost.setPrivateIp("127.0.0.1");
|
||||
instances.add(azureHost);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AzureInstanceXmlParserTest {
|
|||
InputStream inputStream = AzureInstanceXmlParserTest.class.getResourceAsStream("/org/elasticsearch/azure/test/services.xml");
|
||||
Set<Instance> instances = AzureComputeServiceImpl.buildInstancesFromXml(inputStream, "elasticsearch");
|
||||
|
||||
Set<Instance> expected = new HashSet<Instance>();
|
||||
Set<Instance> expected = new HashSet<>();
|
||||
expected.add(build("es-windows2008", "10.53.250.55", null, null, Instance.Status.STARTED));
|
||||
expected.add(build("myesnode1", "10.53.218.75", "137.116.213.150", "9300", Instance.Status.STARTED));
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public class AzureStorageServiceMock extends AbstractLifecycleComponent<AzureStorageServiceMock>
|
||||
implements AzureStorageService {
|
||||
|
||||
protected Map<String, ByteArrayOutputStream> blobs = new ConcurrentHashMap<String, ByteArrayOutputStream>();
|
||||
protected Map<String, ByteArrayOutputStream> blobs = new ConcurrentHashMap<>();
|
||||
|
||||
@Inject
|
||||
protected AzureStorageServiceMock(Settings settings) {
|
||||
|
|
Loading…
Reference in New Issue