Skip to content

Commit

Permalink
Improvements when searching peers.
Browse files Browse the repository at this point in the history
Khernet.App.Container update to version 1.0.11
  • Loading branch information
Luis committed Nov 16, 2020
1 parent 58e6606 commit 293931d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* Definition for the GET_CONNECTED_PEERS procedure : */
/* Definition for the GET_SERVICE_ADDRESSES procedure : */

------------------------------------------------------------------------------
-- Create date: 2020-02-15
-- Create date: 2020-11-15
-- Autor: Luis Lema
--
-- Description:
-- Get the list of peers that are online.
-- Get the list of address of a type of service.
--
-- Parameters:
-- SERVICE_TYPE - The type of service each peer publish
-- SERVICE_TYPE - The type of service each peer publish.
--
-- Returns:
-- The list of service addresses.
------------------------------------------------------------------------------

CREATE OR ALTER PROCEDURE GET_CONNECTED_PEERS
CREATE OR ALTER PROCEDURE GET_SERVICE_ADDRESSES
(
SERVICE_TYPE TYPE OF COLUMN PEER_ADDRESS.SERV_TYPE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Khernet.App.Container.1.0.10\build\Khernet.App.Container.targets" Condition="Exists('..\..\packages\Khernet.App.Container.1.0.10\build\Khernet.App.Container.targets')" />
<Import Project="..\..\packages\Khernet.App.Container.1.0.11\build\Khernet.App.Container.targets" Condition="Exists('..\..\packages\Khernet.App.Container.1.0.11\build\Khernet.App.Container.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Khernet.App.Container.1.0.10\build\Khernet.App.Container.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Khernet.App.Container.1.0.10\build\Khernet.App.Container.targets'))" />
<Error Condition="!Exists('..\..\packages\Khernet.App.Container.1.0.11\build\Khernet.App.Container.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Khernet.App.Container.1.0.11\build\Khernet.App.Container.targets'))" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion Khernet.Core/Engine/Khernet.Core.Container/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Khernet.App.Container" version="1.0.10" targetFramework="net40" />
<package id="Khernet.App.Container" version="1.0.11" targetFramework="net40" />
</packages>
9 changes: 7 additions & 2 deletions Khernet.Core/Engine/Khernet.Core.Data/CommunicatorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,13 +1166,18 @@ public DataTable GetPeerServAddress(string token, string serviceType)
}
}

public DataTable GetConnectedPeers(string serviceType)
/// <summary>
/// Gets a specified type of service addresses of all peers.
/// </summary>
/// <param name="serviceType">The service type to get addresses to.</param>
/// <returns>The list of addresses.</returns>
public DataTable GetServiceAdresses(string serviceType)
{
try
{
DataTable table = new DataTable();

FbCommand cmd = new FbCommand("GET_CONNECTED_PEERS");
FbCommand cmd = new FbCommand("GET_SERVICE_ADDRESSES");
cmd.CommandType = CommandType.StoredProcedure;

var keys = EncryptionHelper.UnpackAESKeys(Obfuscator.Key);
Expand Down
12 changes: 8 additions & 4 deletions Khernet.Core/Engine/Khernet.Core.Host/PeerWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ private void discoveryClient_FindProgressChanged(object sender, FindProgressChan

if (comm.GetPeerAdress(foundToken, Constants.FileService) == null)
SavePeerAddress(e.EndpointDiscoveryMetadata, identity);

IoCContainer.Get<PendingMessageManager>().ProcessPendingMessagesOf(foundToken);
});
}

Expand Down Expand Up @@ -152,8 +154,6 @@ private static void SavePeerAddress(EndpointDiscoveryMetadata metadata, PeerIden
tempAddress,//Address of service
metadata.Extensions.Elements(Constants.ServiceIDTag).FirstOrDefault().Value//Type of service
);

IoCContainer.Get<PendingMessageManager>().ProcessPendingMessagesOf(token);
}
}
}
Expand Down Expand Up @@ -404,7 +404,7 @@ private void ProbePeerState()
{
try
{
List<PeerAddress> tokenList = communicator.GetConnectedPeers(Constants.CommunicatorService);
List<PeerAddress> tokenList = communicator.GetServiceAdresses(Constants.CommunicatorService);

bool existsDisconnected = false;
for (int i = 0; i < tokenList.Count; i++)
Expand All @@ -413,14 +413,15 @@ private void ProbePeerState()
if (!Uri.TryCreate(tokenList[i].Address, UriKind.Absolute, out addr))
{
existsDisconnected = true;
continue;
break;
}

if (NetworkHelper.IsIPAddress(addr.Host))
{
if (!NetworkHelper.TryConnectToIP(addr.Host, addr.Port))
{
existsDisconnected = true;
break;
}
else
{
Expand All @@ -433,6 +434,7 @@ private void ProbePeerState()
else if (!NetworkHelper.TryConnectToHost(addr.Host, addr.Port))
{
existsDisconnected = true;
break;
}
else
{
Expand Down Expand Up @@ -480,6 +482,8 @@ private void announcementService_OnlineAnnouncementReceived(object sender, Annou
{
//Save peer on database
SavePeerAddress(e.EndpointDiscoveryMetadata, identity);

IoCContainer.Get<PendingMessageManager>().ProcessPendingMessagesOf(GetToken(e.EndpointDiscoveryMetadata));
}
}
catch (Exception exception)
Expand Down
9 changes: 7 additions & 2 deletions Khernet.Core/Engine/Khernet.Core.Processor/Communicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,15 @@ public void ClearPeersState()
commData.ClearPeersState();
}

public List<PeerAddress> GetConnectedPeers(string serviceType)
/// <summary>
/// Gets a specified type of service addresses of all peers.
/// </summary>
/// <param name="serviceType">The service type to get addresses to.</param>
/// <returns>The list of addresses.</returns>
public List<PeerAddress> GetServiceAdresses(string serviceType)
{
CommunicatorData commData = new CommunicatorData();
DataTable data = commData.GetConnectedPeers(serviceType);
DataTable data = commData.GetServiceAdresses(serviceType);

List<PeerAddress> addressList = new List<PeerAddress>();
for (int i = 0; i < data.Rows.Count; i++)
Expand Down
4 changes: 2 additions & 2 deletions Khernet.UI/Khernet.UI.Presentation/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
// mediante el carácter '*', como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.13.8.0")]
[assembly: AssemblyFileVersion("0.13.8.0")]
[assembly: AssemblyVersion("0.13.9.0")]
[assembly: AssemblyFileVersion("0.13.9.0")]

0 comments on commit 293931d

Please sign in to comment.