Project

General

Profile

ConfirmedNode.java

Rob Nahf, 2019-02-15 19:36

Download (1.02 KB)

 
1
package org.dataone.cn.rest;
2

    
3
import org.dataone.service.types.v1.NodeReference;
4

    
5
/**
6
 * A helper class for UrlChecker.  This class represents the shared state between UrlCheckers
7
 * running concurrently on different threads, as well as the desired result.
8
 * 
9
 * Note that in this case, shared state doesn't require any race-condition avoidance, because
10
 * any answer is as good as the one it might overwrite. Without synchronization or locks, the code
11
 * stays very simple.
12
 * 
13
 * 
14
 * @author rnahf
15
 *
16
 */
17
public class ConfirmedNode {
18

    
19
    private NodeReference nr;
20
    
21
    // one would think we should synchronize this method, but since we don't care about
22
    // the final answer (they are all correct), we can save some overhead.
23
    public void setNodeReference(NodeReference confirmedNode) {
24
        if (this.nr == null && confirmedNode != null) {
25
            // only a valid NodeReference can reach here
26
            this.nr = confirmedNode;
27
        }
28
    }
29
    public NodeReference getNodeReference() {
30
        return this.nr;
31
    }
32

    
33
}
Add picture from clipboard (Maximum size: 14.8 MB)