Yuta HIGUCHI

Sliced out Provider-ish API from ClockService

Change-Id: I438815f2dc7a3a304f7dc8fb09550b2a5f779265
1 +package org.onlab.onos.store;
2 +
3 +import org.onlab.onos.cluster.MastershipTerm;
4 +import org.onlab.onos.net.DeviceId;
5 +
6 +//TODO: Consider renaming to DeviceClockProviderService?
7 +/**
8 +* Interface for feeding term information to a logical clock service
9 +* that vends per device timestamps.
10 +*/
11 +public interface ClockProviderService {
12 +
13 + /**
14 + * Updates the mastership term for the specified deviceId.
15 + * @param deviceId device identifier.
16 + * @param term mastership term.
17 + */
18 + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term);
19 +}
1 package org.onlab.onos.store; 1 package org.onlab.onos.store;
2 2
3 -import org.onlab.onos.cluster.MastershipTerm;
4 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
5 4
6 // TODO: Consider renaming to DeviceClockService? 5 // TODO: Consider renaming to DeviceClockService?
...@@ -15,12 +14,4 @@ public interface ClockService { ...@@ -15,12 +14,4 @@ public interface ClockService {
15 * @return timestamp. 14 * @return timestamp.
16 */ 15 */
17 public Timestamp getTimestamp(DeviceId deviceId); 16 public Timestamp getTimestamp(DeviceId deviceId);
18 -
19 - // TODO: Should this be here or separate as Admin service, etc.?
20 - /**
21 - * Updates the mastership term for the specified deviceId.
22 - * @param deviceId device identifier.
23 - * @param term mastership term.
24 - */
25 - public void setMastershipTerm(DeviceId deviceId, MastershipTerm term);
26 } 17 }
......
...@@ -38,7 +38,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; ...@@ -38,7 +38,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate;
38 import org.onlab.onos.net.device.PortDescription; 38 import org.onlab.onos.net.device.PortDescription;
39 import org.onlab.onos.net.provider.AbstractProviderRegistry; 39 import org.onlab.onos.net.provider.AbstractProviderRegistry;
40 import org.onlab.onos.net.provider.AbstractProviderService; 40 import org.onlab.onos.net.provider.AbstractProviderService;
41 -import org.onlab.onos.store.ClockService; 41 +import org.onlab.onos.store.ClockProviderService;
42 import org.slf4j.Logger; 42 import org.slf4j.Logger;
43 43
44 /** 44 /**
...@@ -80,7 +80,7 @@ public class DeviceManager ...@@ -80,7 +80,7 @@ public class DeviceManager
80 protected MastershipTermService termService; 80 protected MastershipTermService termService;
81 81
82 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 82 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
83 - protected ClockService clockService; 83 + protected ClockProviderService clockProviderService;
84 84
85 @Activate 85 @Activate
86 public void activate() { 86 public void activate() {
...@@ -274,7 +274,7 @@ public class DeviceManager ...@@ -274,7 +274,7 @@ public class DeviceManager
274 if (event.master().equals(clusterService.getLocalNode().id())) { 274 if (event.master().equals(clusterService.getLocalNode().id())) {
275 MastershipTerm term = mastershipService.requestTermService() 275 MastershipTerm term = mastershipService.requestTermService()
276 .getMastershipTerm(event.subject()); 276 .getMastershipTerm(event.subject());
277 - clockService.setMastershipTerm(event.subject(), term); 277 + clockProviderService.setMastershipTerm(event.subject(), term);
278 applyRole(event.subject(), MastershipRole.MASTER); 278 applyRole(event.subject(), MastershipRole.MASTER);
279 } else { 279 } else {
280 applyRole(event.subject(), MastershipRole.STANDBY); 280 applyRole(event.subject(), MastershipRole.STANDBY);
......
...@@ -12,6 +12,7 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -12,6 +12,7 @@ import org.apache.felix.scr.annotations.Deactivate;
12 import org.apache.felix.scr.annotations.Service; 12 import org.apache.felix.scr.annotations.Service;
13 import org.onlab.onos.cluster.MastershipTerm; 13 import org.onlab.onos.cluster.MastershipTerm;
14 import org.onlab.onos.net.DeviceId; 14 import org.onlab.onos.net.DeviceId;
15 +import org.onlab.onos.store.ClockProviderService;
15 import org.onlab.onos.store.ClockService; 16 import org.onlab.onos.store.ClockService;
16 import org.onlab.onos.store.Timestamp; 17 import org.onlab.onos.store.Timestamp;
17 import org.onlab.onos.store.impl.OnosTimestamp; 18 import org.onlab.onos.store.impl.OnosTimestamp;
...@@ -22,7 +23,7 @@ import org.slf4j.Logger; ...@@ -22,7 +23,7 @@ import org.slf4j.Logger;
22 */ 23 */
23 @Component(immediate = true) 24 @Component(immediate = true)
24 @Service 25 @Service
25 -public class DeviceClockManager implements ClockService { 26 +public class DeviceClockManager implements ClockService, ClockProviderService {
26 27
27 private final Logger log = getLogger(getClass()); 28 private final Logger log = getLogger(getClass());
28 29
......
...@@ -4,27 +4,15 @@ import org.apache.felix.scr.annotations.Component; ...@@ -4,27 +4,15 @@ import org.apache.felix.scr.annotations.Component;
4 import org.apache.felix.scr.annotations.Service; 4 import org.apache.felix.scr.annotations.Service;
5 import org.onlab.onos.cluster.MastershipTerm; 5 import org.onlab.onos.cluster.MastershipTerm;
6 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
7 -import org.onlab.onos.store.ClockService; 7 +import org.onlab.onos.store.ClockProviderService;
8 -import org.onlab.onos.store.Timestamp;
9 8
10 // FIXME: Code clone in onos-core-trivial, onos-core-hz-net 9 // FIXME: Code clone in onos-core-trivial, onos-core-hz-net
11 /** 10 /**
12 - * Dummy implementation of {@link ClockService}. 11 + * Dummy implementation of {@link ClockProviderService}.
13 */ 12 */
14 @Component(immediate = true) 13 @Component(immediate = true)
15 @Service 14 @Service
16 -public class NoOpClockService implements ClockService { 15 +public class NoOpClockProviderService implements ClockProviderService {
17 -
18 - @Override
19 - public Timestamp getTimestamp(DeviceId deviceId) {
20 - return new Timestamp() {
21 -
22 - @Override
23 - public int compareTo(Timestamp o) {
24 - throw new IllegalStateException("Never expected to be used.");
25 - }
26 - };
27 - }
28 16
29 @Override 17 @Override
30 public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { 18 public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
......
...@@ -4,27 +4,15 @@ import org.apache.felix.scr.annotations.Component; ...@@ -4,27 +4,15 @@ import org.apache.felix.scr.annotations.Component;
4 import org.apache.felix.scr.annotations.Service; 4 import org.apache.felix.scr.annotations.Service;
5 import org.onlab.onos.cluster.MastershipTerm; 5 import org.onlab.onos.cluster.MastershipTerm;
6 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
7 -import org.onlab.onos.store.ClockService; 7 +import org.onlab.onos.store.ClockProviderService;
8 -import org.onlab.onos.store.Timestamp;
9 8
10 //FIXME: Code clone in onos-core-trivial, onos-core-hz-net 9 //FIXME: Code clone in onos-core-trivial, onos-core-hz-net
11 /** 10 /**
12 - * Dummy implementation of {@link ClockService}. 11 + * Dummy implementation of {@link ClockProviderService}.
13 */ 12 */
14 @Component(immediate = true) 13 @Component(immediate = true)
15 @Service 14 @Service
16 -public class NoOpClockService implements ClockService { 15 +public class NoOpClockProviderService implements ClockProviderService {
17 -
18 - @Override
19 - public Timestamp getTimestamp(DeviceId deviceId) {
20 - return new Timestamp() {
21 -
22 - @Override
23 - public int compareTo(Timestamp o) {
24 - throw new IllegalStateException("Never expected to be used.");
25 - }
26 - };
27 - }
28 16
29 @Override 17 @Override
30 public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { 18 public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
......