1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
package javax.jmdns.impl.tasks.state; |
6 |
|
|
7 |
|
import java.io.IOException; |
8 |
|
import java.util.Timer; |
9 |
|
import java.util.logging.Logger; |
10 |
|
|
11 |
|
import javax.jmdns.impl.DNSOutgoing; |
12 |
|
import javax.jmdns.impl.DNSRecord; |
13 |
|
import javax.jmdns.impl.JmDNSImpl; |
14 |
|
import javax.jmdns.impl.ServiceInfoImpl; |
15 |
|
import javax.jmdns.impl.constants.DNSConstants; |
16 |
|
import javax.jmdns.impl.constants.DNSRecordClass; |
17 |
|
import javax.jmdns.impl.constants.DNSState; |
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
|
|
| 19% |
Uncovered Elements: 34 (42) |
Complexity: 16 |
Complexity Density: 0.67 |
|
22 |
|
public class Renewer extends DNSStateTask { |
23 |
|
static Logger logger = Logger.getLogger(Renewer.class.getName()); |
24 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
25 |
51
|
public Renewer(JmDNSImpl jmDNSImpl) {... |
26 |
51
|
super(jmDNSImpl, defaultTTL()); |
27 |
|
|
28 |
51
|
this.setTaskState(DNSState.ANNOUNCED); |
29 |
51
|
this.associate(DNSState.ANNOUNCED); |
30 |
|
} |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@see |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
36 |
0
|
@Override... |
37 |
|
public String getName() { |
38 |
0
|
return "Renewer(" + (this.getDns() != null ? this.getDns().getName() : "") + ")"; |
39 |
|
} |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@see |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
45 |
0
|
@Override... |
46 |
|
public String toString() { |
47 |
0
|
return super.toString() + " state: " + this.getTaskState(); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@see |
53 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
54 |
51
|
@Override... |
55 |
|
public void start(Timer timer) { |
56 |
51
|
if (!this.getDns().isCanceling() && !this.getDns().isCanceled()) { |
57 |
51
|
timer.schedule(this, DNSConstants.ANNOUNCED_RENEWAL_TTL_INTERVAL, DNSConstants.ANNOUNCED_RENEWAL_TTL_INTERVAL); |
58 |
|
} |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
0
|
@Override... |
62 |
|
public boolean cancel() { |
63 |
0
|
this.removeAssociation(); |
64 |
|
|
65 |
0
|
return super.cancel(); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@see |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0
|
@Override... |
73 |
|
public String getTaskDescription() { |
74 |
0
|
return "renewing"; |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
@see |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0
|
@Override... |
82 |
|
protected boolean checkRunCondition() { |
83 |
0
|
return !this.getDns().isCanceling() && !this.getDns().isCanceled(); |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@see |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0
|
@Override... |
91 |
|
protected DNSOutgoing createOugoing() { |
92 |
0
|
return new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
@see |
98 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
99 |
0
|
@Override... |
100 |
|
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException { |
101 |
0
|
DNSOutgoing newOut = out; |
102 |
0
|
for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.UNIQUE, this.getTTL())) { |
103 |
0
|
newOut = this.addAnswer(newOut, null, answer); |
104 |
|
} |
105 |
0
|
return newOut; |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
@see |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
112 |
0
|
@Override... |
113 |
|
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException { |
114 |
0
|
DNSOutgoing newOut = out; |
115 |
0
|
for (DNSRecord answer : info.answers(DNSRecordClass.UNIQUE, this.getTTL(), this.getDns().getLocalHost())) { |
116 |
0
|
newOut = this.addAnswer(newOut, null, answer); |
117 |
|
} |
118 |
0
|
return newOut; |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
@see |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
0
|
@Override... |
126 |
|
protected void recoverTask(Throwable e) { |
127 |
0
|
this.getDns().recover(); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@see |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
134 |
0
|
@Override... |
135 |
|
protected void advanceTask() { |
136 |
0
|
this.setTaskState(this.getTaskState().advance()); |
137 |
0
|
if (!this.getTaskState().isAnnounced()) { |
138 |
0
|
cancel(); |
139 |
|
} |
140 |
|
} |
141 |
|
} |