Skip to content

Commit

Permalink
Merge pull request #15 from Saetch/9-increase_speed
Browse files Browse the repository at this point in the history
9 increase speed
  • Loading branch information
Saetch authored May 26, 2024
2 parents 2071788 + d60f0d5 commit 7f43dbd
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 46 deletions.
26 changes: 25 additions & 1 deletion Cluster/Node_cs/ApiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ private void registerRequests(WebApplication app)
return Results.BadRequest(e.Message);
}
});

app.MapGet("/getMultipleSavedValues", async (String parameters) => {
try {
Console.WriteLine("Received getMultipleSavedValues-call with params: " + parameters );
var retVal = await NodeBehavior.GetMultipleSavedValues(parameters, this);
return Results.Ok(retVal);
} catch (Exception e) {
return Results.BadRequest(e.Message);
}
});



Expand Down Expand Up @@ -179,6 +187,12 @@ private void DealWithResponse(HttpResponseMessage response){

}


public class SavedValue{
public required Position Position { get; set; }
public double value { get; set; }
}

public class XYValues
{
public double x { get; set; }
Expand All @@ -197,6 +211,12 @@ public class Position{
public int y { get; set; }
}

public class NodeResponse{
public required String name {get; set;}

public ushort hash {get; set;}
}

[JsonSerializable(typeof(String))]
[JsonSerializable(typeof(List<XYValues>))]
[JsonSerializable(typeof(List<Position>))]
Expand All @@ -206,6 +226,10 @@ public class Position{
[JsonSerializable(typeof(XYValues[]))]
[JsonSerializable(typeof(HashedPosition))]
[JsonSerializable(typeof(List<HashedPosition>))]
[JsonSerializable(typeof(Tuple<int, int>))]
[JsonSerializable(typeof(List<Tuple<int, int>>))]
[JsonSerializable(typeof(NodeResponse))]
[JsonSerializable(typeof(List<NodeResponse>))]
internal partial class AppJsonSerializerContext : JsonSerializerContext
{

Expand Down
1 change: 1 addition & 0 deletions Cluster/Node_cs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ RUN dotnet publish "Node_cs.csproj" -c Release -o /app/publish /p:UseAppHost=fal
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
RUN apk add curl
ENTRYPOINT ["dotnet", "Node_cs.dll"]
4 changes: 2 additions & 2 deletions Cluster/Node_cs/Dockerfiles/aot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ RUN dotnet build -c Release -o /app/build
RUN apt-get update && \
apt-get install -y clang zlib1g-dev
# Publish the application
RUN dotnet publish -p:PublishAot=true -p:StripSymbols=true -c Debug -o /app/publish -r linux-musl-x64
RUN dotnet publish -p:PublishAot=true -p:StripSymbols=true -c Release -o /app/publish -r linux-musl-x64

# Switch to the runtime image
FROM alpine:3.19 AS runtime
RUN apk add libc6-compat

# Set the working directory inside the Docker image
WORKDIR /app

RUN apk add curl
# Copy the published application
COPY --from=build /app/publish/* .
# Set the entry point for the container
Expand Down
2 changes: 0 additions & 2 deletions Cluster/Node_cs/GetRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ static async Task<double> CalculateInterpolatedValue(double x, double y, ApiConf
public static double? GetSavedNodeValue(int x, int y, ApiConfig config){
Console.WriteLine("Received SavedValue-call with params: " + x + "/" + y);
Tuple<int, int> key = new Tuple<int, int>(x, y);
DisplayState(config);
if(config.savedValues.ContainsKey(key)){
return config.savedValues[key];
}
return null;
}

private static void DisplayState(ApiConfig config){
Console.WriteLine("State: " + config.savedValues);
Tuple<int, int>[] keys = config.savedValues.Keys.ToArray();
for (int i = 0; i < keys.Length; i++)
{
Expand Down
Loading

0 comments on commit 7f43dbd

Please sign in to comment.