Skip to content

Commit

Permalink
[Fix-275][api] remove the host from the cache when delete the host (#302
Browse files Browse the repository at this point in the history
)

Co-authored-by: luting <dylzlt93299@gmail.com>
  • Loading branch information
hzluting and luting authored Jun 29, 2023
1 parent 9a8a8b8 commit 1539ad3
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.datasophon.common.command.ExecuteCmdCommand;
import com.datasophon.common.command.GenerateHostPrometheusConfig;
import com.datasophon.common.command.GenerateRackPropCommand;
import com.datasophon.common.model.HostInfo;
import com.datasophon.common.utils.Result;
import com.datasophon.dao.entity.ClusterHostEntity;
import com.datasophon.dao.entity.ClusterInfoEntity;
Expand All @@ -48,6 +49,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -156,6 +158,12 @@ public Result deleteHost(Integer hostId) {
prometheusActor.tell(prometheusConfigCommand, ActorRef.noSender());

this.removeById(hostId);

// remove the host from the cache
Map<String, HostInfo> map =
(Map<String, HostInfo>) CacheUtils.get(clusterCode + Constants.HOST_MAP);
map.remove(host.getHostname());

return Result.success();
}

Expand Down

0 comments on commit 1539ad3

Please sign in to comment.