Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
/bin/
/target/
CVS/

.vscode/
35 changes: 33 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -115,6 +121,31 @@
</configuration>
</plugin>
</plugins>
</pluginManagement>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>org.midas.ms.MasServer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
2 changes: 1 addition & 1 deletion src/main/java/org/midas/metainfo/NativeComponentInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String toString()
{
String aux="";

aux+= ("Component: "+getName()+"\n\n");
aux+= ("Component: "+getName()+"\n\n");
aux+= ("Protocol: \n - ");
aux+= (getProtocol()+"\n\n");
aux+= ("Package: \n - ");
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/midas/metainfo/ServiceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ public class ServiceInfo implements Comparable,Serializable
private String path;
private String scope;
private String description;
private String port;

private EntityInfo entity;
private Set<ParameterInfo> parameters = new TreeSet<ParameterInfo>();

public ServiceInfo(String name,String path,String scope,String description,EntityInfo entity)
public ServiceInfo(String name,String path,String scope,String description, String port,EntityInfo entity)
{
this.name = new String(name);
this.path = new String(path);
this.scope = new String(scope);
this.description = new String(description);
this.port = port;
this.entity = entity;
}

Expand Down Expand Up @@ -57,6 +59,14 @@ public EntityInfo getEntity()
{
return (entity);
}

public String getPort() {
return this.port;
}

public void setPort(String port) {
this.port = port;
}

public Set getParameters()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public String toString()
{
String aux="";

aux+= ("Component: "+getName()+"\n\n");
aux+= ("Component: "+getName()+"\n\n");
aux+= ("Protocol: \n - ");
aux+= (getProtocol()+"\n\n");
aux+= ("Url: \n - ");
Expand Down
52 changes: 49 additions & 3 deletions src/main/java/org/midas/ms/trader/Trader.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@ else if (requisitionType.equals("verify"))
{
verifyRequest(req,res);
}
else if (requisitionType.equals("deregister"))
{
try
{
deregisterRequest(req,res);
}
catch (CatalogException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
else
{
throw new IOException("Invalid Requisition - Expected parameter 'type' with requisition type {register,verify,provide,ping}");
Expand Down Expand Up @@ -127,7 +146,7 @@ private void verifyRequest(HttpServletRequest req, HttpServletResponse res) thro
private void provideRequest(HttpServletRequest req, HttpServletResponse res) throws IOException
{
// Serviço
HashMap in;
Object in;
String service;
String organization;

Expand Down Expand Up @@ -157,7 +176,7 @@ private void provideRequest(HttpServletRequest req, HttpServletResponse res) thr
requirer = ois.readUTF();
organization = ois.readUTF();
service = ois.readUTF();
in = (HashMap)ois.readObject();
in = ois.readObject();
}
catch (ClassNotFoundException e)
{
Expand All @@ -176,7 +195,7 @@ private void provideRequest(HttpServletRequest req, HttpServletResponse res) thr
endTime = System.currentTimeMillis();

// Logando Resultados
LOG.warn("Unknown service required - Timing: "+(endTime-startTime)+"ms - Requirer: not found - Provider: not found | "+message,false);
LOG.warn("Unknown service required - Timing: "+(endTime-startTime)+"ms - Requirer: not found - Provider: not found | "+message,e);

return;
}
Expand Down Expand Up @@ -401,6 +420,33 @@ private void registerRequest(HttpServletRequest req, HttpServletResponse res) th
ManagerScreen.userInterfaceEvent("Refresh Services");
}

private void deregisterRequest(HttpServletRequest req, HttpServletResponse res) throws IOException, ClassNotFoundException, CatalogException
{
Object data;

// Recuperando Entrada da Requisição
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(req.getInputStream()));
data = in.readObject();

in.close();

// Construindo Resposta da Requisição
res.setStatus(HttpServletResponse.SC_OK);

ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(res.getOutputStream()));

oos.writeUTF("registered");
oos.flush();
oos.close();

// Tratando Objeto Recebido
// TODO: Delegar responsabilidade de notificação do ManagerScreen ao Catalog
ContainerInfo containerData = (ContainerInfo)data;

Catalog.removeContainer(containerData);
LOG.info("Container '"+containerData.getName()+"' has been removed from MAS");
}

public static boolean ping(ContainerInfo container)
{
try
Expand Down