[ 
https://issues.apache.org/jira/browse/GOSSIP-79?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15973941#comment-15973941
 ] 

ASF GitHub Bot commented on GOSSIP-79:
--------------------------------------

Github user edwardcapriolo commented on a diff in the pull request:

    https://github.com/apache/incubator-gossip/pull/47#discussion_r112105097
  
    --- Diff: 
gossip-base/src/main/java/org/apache/gossip/manager/RingStatePersister.java ---
    @@ -26,51 +26,50 @@
     import java.util.List;
     import java.util.NavigableSet;
     
    +import com.fasterxml.jackson.core.JsonGenerator;
    +import com.fasterxml.jackson.databind.ObjectMapper;
     import org.apache.gossip.LocalMember;
    +import org.apache.gossip.crdt.CrdtModule;
     import org.apache.log4j.Logger;
     
     public class RingStatePersister implements Runnable {
     
       private static final Logger LOGGER = 
Logger.getLogger(RingStatePersister.class);
    -  private GossipManager parent;
    +  private final File path;
    +  // NOTE: this is a different instance than what gets used for message 
marshalling.
    +  private final ObjectMapper objectMapper;
    +  private final GossipManager manager;
       
    -  public RingStatePersister(GossipManager parent){
    -    this.parent = parent;
    +  public RingStatePersister(File path, GossipManager manager){
    +    this.path = path;
    +    this.objectMapper = GossipManager.metdataObjectMapper;
    +    this.manager = manager;
       }
       
       @Override
       public void run() {
         writeToDisk();
       }
       
    -  File computeTarget(){
    -    return new File(parent.getSettings().getPathToRingState(), 
"ringstate." + parent.getMyself().getClusterName() + "." 
    -            + parent.getMyself().getId() + ".json");
    -  }
    -  
    -  void writeToDisk(){
    -    if (!parent.getSettings().isPersistRingState()){
    -      return;
    -    }
    -    NavigableSet<LocalMember> i = parent.getMembers().keySet();
    -    try (FileOutputStream fos = new FileOutputStream(computeTarget())){
    -      parent.getObjectMapper().writeValue(fos, i);
    +  void writeToDisk() {
    +    NavigableSet<LocalMember> i = manager.getMembers().keySet();
    +    try (FileOutputStream fos = new FileOutputStream(path)){
    +      objectMapper.writeValue(fos, i);
         } catch (IOException e) {
           LOGGER.debug(e);
         }
       }
     
       @SuppressWarnings("unchecked")
    -  List<LocalMember> readFromDisk(){
    -    if (!parent.getSettings().isPersistRingState()){
    +  List<LocalMember> readFromDisk() {
    +    if (!path.exists()) {
           return Collections.emptyList();
    --- End diff --
    
    I wonder if this needs to be mutable like the other method incase we wish 
to edit the list later?


> create gossip-transport-udp module
> ----------------------------------
>
>                 Key: GOSSIP-79
>                 URL: https://issues.apache.org/jira/browse/GOSSIP-79
>             Project: Gossip
>          Issue Type: Improvement
>            Reporter: Gary Dusbabek
>            Assignee: Gary Dusbabek
>
> Create a transport module that houses the UDP transport.
> This will probably require some refactoring. It may be prudent to create a 
> few interfaces that are kept in gossip-core which are then implemented in 
> gossip-transport-udp.
> This probably needs to be a modules
> 1 udp-server
> 2 udp-client
> OtherThings:
> GossipManager.build() needs to look at the URI and dynamically load the right 
> server
> GossipCore.send() needs to locate the right client for a URI.
> Both of these things probably need a registry. Please dont make it a static 
> singleton thing ! :)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to