ing
This commit is contained in:
parent
77e018f99a
commit
54053757a3
|
@ -4,12 +4,10 @@ import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +26,7 @@ public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
|
||||||
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
|
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
|
||||||
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
|
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
|
||||||
|
|
||||||
@Modifying(clearAutomatically = true)
|
// @Modifying(clearAutomatically = true)
|
||||||
@Query("UPDATE NoAuthProbe n set n.connectDate = :connectDate, n.connectAddress = :connectAddress where n.tempProbeKey = :tempProbeKey")
|
// @Query("UPDATE NoAuthProbe n set n.connectDate = :connectDate, n.connectAddress = :connectAddress where n.tempProbeKey = :tempProbeKey")
|
||||||
int saveConnect(@Param("tempProbeKey") String tempProbeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
|
// int saveConnect(@Param("tempProbeKey") String tempProbeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,11 +221,21 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConnect(String tempKey, String connectAddress) throws OverflowException {
|
public void onConnect(String tempKey, String connectAddress) throws OverflowException {
|
||||||
this.noAuthProbeDAO.saveConnect(tempKey, new Date(), connectAddress);
|
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findByTempProbeKey(tempKey);
|
||||||
|
noAuthProbe.setConnectDate(new Date());
|
||||||
|
noAuthProbe.setConnectAddress(connectAddress);
|
||||||
|
noAuthProbe = this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
||||||
|
messagePublisher.publishToDomainMembers(noAuthProbe.getDomain().getId(), "NoAuthProbeService.onConnect", tempKey, connectAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnect(String tempKey) throws OverflowException {
|
public void onDisconnect(String tempKey) throws OverflowException {
|
||||||
this.noAuthProbeDAO.saveConnect(tempKey, null, null);
|
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findByTempProbeKey(tempKey);
|
||||||
|
noAuthProbe.setConnectDate(null);
|
||||||
|
noAuthProbe.setConnectAddress(null);
|
||||||
|
noAuthProbe = this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
||||||
|
messagePublisher.publishToDomainMembers(noAuthProbe.getDomain().getId(), "NoAuthProbeService.onDisconnect", tempKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,8 @@ import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.model.probe.Probe;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +18,7 @@ public interface ProbeDAO extends JpaRepository<Probe, Long> {
|
||||||
Probe findByProbeKey(String probeKey);
|
Probe findByProbeKey(String probeKey);
|
||||||
List<Probe> findAllByDomainOrderByIdDesc(Domain domain);
|
List<Probe> findAllByDomainOrderByIdDesc(Domain domain);
|
||||||
|
|
||||||
@Modifying(clearAutomatically = true)
|
// @Modifying(clearAutomatically = true)
|
||||||
@Query("UPDATE Probe p set p.connectDate = :connectDate, p.connectAddress = :connectAddress where p.probeKey = :probeKey")
|
// @Query("UPDATE Probe p set p.connectDate = :connectDate, p.connectAddress = :connectAddress where p.probeKey = :probeKey")
|
||||||
int saveConnect(@Param("probeKey") String probeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
|
// int saveConnect(@Param("probeKey") String probeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.loafle.overflow.central.module.probe.service;
|
package com.loafle.overflow.central.module.probe.service;
|
||||||
|
|
||||||
|
import com.loafle.overflow.central.commons.service.MessagePublisher;
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
|
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
|
@ -20,6 +21,8 @@ public class CentralProbeService implements ProbeService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProbeDAO probeDAO;
|
private ProbeDAO probeDAO;
|
||||||
|
@Autowired
|
||||||
|
private MessagePublisher messagePublisher;
|
||||||
|
|
||||||
public Probe regist(Probe probe) throws OverflowException {
|
public Probe regist(Probe probe) throws OverflowException {
|
||||||
return this.probeDAO.save(probe);
|
return this.probeDAO.save(probe);
|
||||||
|
@ -73,11 +76,20 @@ public class CentralProbeService implements ProbeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConnect(String probeKey, String connectAddress) throws OverflowException {
|
public void onConnect(String probeKey, String connectAddress) throws OverflowException {
|
||||||
this.probeDAO.saveConnect(probeKey, new Date(), connectAddress);
|
Probe probe = this.probeDAO.findByProbeKey(probeKey);
|
||||||
|
probe.setConnectDate(new Date());
|
||||||
|
probe.setConnectAddress(connectAddress);
|
||||||
|
probe = this.probeDAO.save(probe);
|
||||||
|
|
||||||
|
messagePublisher.publishToDomainMembers(probe.getDomain().getId(), "ProbeService.onConnect", probeKey, connectAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnect(String probeKey) throws OverflowException {
|
public void onDisconnect(String probeKey) throws OverflowException {
|
||||||
this.probeDAO.saveConnect(probeKey, null, null);
|
Probe probe = this.probeDAO.findByProbeKey(probeKey);
|
||||||
}
|
probe.setConnectDate(null);
|
||||||
|
probe.setConnectAddress(null);
|
||||||
|
probe = this.probeDAO.save(probe);
|
||||||
|
|
||||||
|
messagePublisher.publishToDomainMembers(probe.getDomain().getId(), "ProbeService.onDisconnect", probeKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user