CORD Subscriber GUI - Added a little logging.
Change-Id: I96f674008cd8e6b3d7b3f517444a5ef9fd8b761c
Showing
3 changed files
with
18 additions
and
8 deletions
| ... | @@ -29,6 +29,8 @@ import org.onosproject.cord.gui.model.SubscriberUser; | ... | @@ -29,6 +29,8 @@ import org.onosproject.cord.gui.model.SubscriberUser; |
| 29 | import org.onosproject.cord.gui.model.UserFactory; | 29 | import org.onosproject.cord.gui.model.UserFactory; |
| 30 | import org.onosproject.cord.gui.model.XosFunction; | 30 | import org.onosproject.cord.gui.model.XosFunction; |
| 31 | import org.onosproject.cord.gui.model.XosFunctionDescriptor; | 31 | import org.onosproject.cord.gui.model.XosFunctionDescriptor; |
| 32 | +import org.slf4j.Logger; | ||
| 33 | +import org.slf4j.LoggerFactory; | ||
| 32 | 34 | ||
| 33 | import java.util.List; | 35 | import java.util.List; |
| 34 | import java.util.Map; | 36 | import java.util.Map; |
| ... | @@ -50,6 +52,8 @@ public class CordModelCache extends JsonFactory { | ... | @@ -50,6 +52,8 @@ public class CordModelCache extends JsonFactory { |
| 50 | private int subscriberId; | 52 | private int subscriberId; |
| 51 | private Bundle currentBundle; | 53 | private Bundle currentBundle; |
| 52 | 54 | ||
| 55 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
| 56 | + | ||
| 53 | // NOTE: use a tree map to maintain sorted order by user ID | 57 | // NOTE: use a tree map to maintain sorted order by user ID |
| 54 | private final Map<Integer, SubscriberUser> userMap = | 58 | private final Map<Integer, SubscriberUser> userMap = |
| 55 | new TreeMap<Integer, SubscriberUser>(); | 59 | new TreeMap<Integer, SubscriberUser>(); |
| ... | @@ -59,6 +63,7 @@ public class CordModelCache extends JsonFactory { | ... | @@ -59,6 +63,7 @@ public class CordModelCache extends JsonFactory { |
| 59 | * initializing it with basic bundle, and fetching the list of users. | 63 | * initializing it with basic bundle, and fetching the list of users. |
| 60 | */ | 64 | */ |
| 61 | CordModelCache() { | 65 | CordModelCache() { |
| 66 | + log.info("Initialize model cache"); | ||
| 62 | subscriberId = XosManager.INSTANCE.initDemoSubscriber(); | 67 | subscriberId = XosManager.INSTANCE.initDemoSubscriber(); |
| 63 | currentBundle = new Bundle(BundleFactory.BASIC_BUNDLE); | 68 | currentBundle = new Bundle(BundleFactory.BASIC_BUNDLE); |
| 64 | initUsers(); | 69 | initUsers(); |
| ... | @@ -80,6 +85,7 @@ public class CordModelCache extends JsonFactory { | ... | @@ -80,6 +85,7 @@ public class CordModelCache extends JsonFactory { |
| 80 | // memento in which to store the level. | 85 | // memento in which to store the level. |
| 81 | SubscriberUser su = createUser(id, name, mac, level); | 86 | SubscriberUser su = createUser(id, name, mac, level); |
| 82 | userMap.put(id, su); | 87 | userMap.put(id, su); |
| 88 | + log.info("..caching user {} (id:{})", name, id); | ||
| 83 | } | 89 | } |
| 84 | } | 90 | } |
| 85 | 91 | ||
| ... | @@ -108,6 +114,7 @@ public class CordModelCache extends JsonFactory { | ... | @@ -108,6 +114,7 @@ public class CordModelCache extends JsonFactory { |
| 108 | * @throws IllegalArgumentException if bundle ID is unknown | 114 | * @throws IllegalArgumentException if bundle ID is unknown |
| 109 | */ | 115 | */ |
| 110 | public void setCurrentBundle(String bundleId) { | 116 | public void setCurrentBundle(String bundleId) { |
| 117 | + log.info("set new bundle : {}", bundleId); | ||
| 111 | BundleDescriptor bd = BundleFactory.bundleFromId(bundleId); | 118 | BundleDescriptor bd = BundleFactory.bundleFromId(bundleId); |
| 112 | currentBundle = new Bundle(bd); | 119 | currentBundle = new Bundle(bd); |
| 113 | // update the user mementos | 120 | // update the user mementos | ... | ... |
| ... | @@ -42,6 +42,8 @@ public class XosManager { | ... | @@ -42,6 +42,8 @@ public class XosManager { |
| 42 | private static final int TEST_XOS_SERVER_PORT = 8000; | 42 | private static final int TEST_XOS_SERVER_PORT = 8000; |
| 43 | private static final String URI_RS = "/rs/"; | 43 | private static final String URI_RS = "/rs/"; |
| 44 | private static final String URI_SUBSCRIBER = "/rs/subscriber/%d/"; | 44 | private static final String URI_SUBSCRIBER = "/rs/subscriber/%d/"; |
| 45 | + private static final String BUNDLE_URI_FORMAT = "services/%s/%s/"; | ||
| 46 | + | ||
| 45 | 47 | ||
| 46 | private final XosManagerRestUtils xosUtilsRs = | 48 | private final XosManagerRestUtils xosUtilsRs = |
| 47 | new XosManagerRestUtils(TEST_XOS_SERVER_ADDRESS, | 49 | new XosManagerRestUtils(TEST_XOS_SERVER_ADDRESS, |
| ... | @@ -52,8 +54,6 @@ public class XosManager { | ... | @@ -52,8 +54,6 @@ public class XosManager { |
| 52 | 54 | ||
| 53 | private final Logger log = LoggerFactory.getLogger(getClass()); | 55 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 54 | 56 | ||
| 55 | - private int demoId; | ||
| 56 | - | ||
| 57 | /** | 57 | /** |
| 58 | * No instantiation (except via unit test). | 58 | * No instantiation (except via unit test). |
| 59 | */ | 59 | */ |
| ... | @@ -76,7 +76,7 @@ public class XosManager { | ... | @@ -76,7 +76,7 @@ public class XosManager { |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | ObjectNode obj = (ObjectNode) node; | 78 | ObjectNode obj = (ObjectNode) node; |
| 79 | - demoId = obj.get("id").asInt(); | 79 | + int demoId = obj.get("id").asInt(); |
| 80 | log.info("Using DEMO subscriber ID {}.", demoId); | 80 | log.info("Using DEMO subscriber ID {}.", demoId); |
| 81 | 81 | ||
| 82 | String uri = String.format(URI_SUBSCRIBER, demoId); | 82 | String uri = String.format(URI_SUBSCRIBER, demoId); |
| ... | @@ -114,14 +114,15 @@ public class XosManager { | ... | @@ -114,14 +114,15 @@ public class XosManager { |
| 114 | * @param bundle new bundle to set | 114 | * @param bundle new bundle to set |
| 115 | */ | 115 | */ |
| 116 | public void setNewBundle(Bundle bundle) { | 116 | public void setNewBundle(Bundle bundle) { |
| 117 | - log.info("\n>> Set New Bundle : " + bundle.descriptor().id()); | 117 | + log.info(">> Set New Bundle : {}", bundle.descriptor().id()); |
| 118 | 118 | ||
| 119 | - String uriFmt = "services/%s/%s"; | ||
| 120 | Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions(); | 119 | Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions(); |
| 121 | for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) { | 120 | for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) { |
| 122 | // only process the functions that have a real back-end on XOS | 121 | // only process the functions that have a real back-end on XOS |
| 123 | if (xfd.backend()) { | 122 | if (xfd.backend()) { |
| 124 | - String uri = String.format(uriFmt, xfd.id(), inBundle.contains(xfd)); | 123 | + String uri = String.format(BUNDLE_URI_FORMAT, xfd.id(), |
| 124 | + inBundle.contains(xfd)); | ||
| 125 | + log.info("XOS-URI: {}", uri); | ||
| 125 | String result = xosUtils.putRest(uri); | 126 | String result = xosUtils.putRest(uri); |
| 126 | // TODO: convert JSON result to object and check (if we care) | 127 | // TODO: convert JSON result to object and check (if we care) |
| 127 | } | 128 | } |
| ... | @@ -136,10 +137,11 @@ public class XosManager { | ... | @@ -136,10 +137,11 @@ public class XosManager { |
| 136 | * @param user user (containing function state) | 137 | * @param user user (containing function state) |
| 137 | */ | 138 | */ |
| 138 | public void apply(XosFunction func, SubscriberUser user) { | 139 | public void apply(XosFunction func, SubscriberUser user) { |
| 139 | - log.info("\n>> Apply : " + func + " for " + user); | 140 | + log.info(">> Apply : {} for {}", func, user); |
| 140 | 141 | ||
| 141 | String uriPrefix = "users/" + user.id() + "/"; | 142 | String uriPrefix = "users/" + user.id() + "/"; |
| 142 | String uri = uriPrefix + func.xosUrlApply(user); | 143 | String uri = uriPrefix + func.xosUrlApply(user); |
| 144 | + log.info("XOS-URI: {}", uri); | ||
| 143 | String result = xosUtils.putRest(uri); | 145 | String result = xosUtils.putRest(uri); |
| 144 | // TODO: convert JSON result to object and check (if we care) | 146 | // TODO: convert JSON result to object and check (if we care) |
| 145 | } | 147 | } | ... | ... |
| ... | @@ -27,6 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -27,6 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 27 | public class UrlFilterFunction extends DefaultXosFunction { | 27 | public class UrlFilterFunction extends DefaultXosFunction { |
| 28 | 28 | ||
| 29 | private static final String LEVEL = "level"; | 29 | private static final String LEVEL = "level"; |
| 30 | + private static final String URI_PATTERN = "%s/%s/"; | ||
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | * Denotes the URL filtering levels available. From most restrictive | 33 | * Denotes the URL filtering levels available. From most restrictive |
| ... | @@ -87,6 +88,6 @@ public class UrlFilterFunction extends DefaultXosFunction { | ... | @@ -87,6 +88,6 @@ public class UrlFilterFunction extends DefaultXosFunction { |
| 87 | public String xosUrlApply(SubscriberUser user) { | 88 | public String xosUrlApply(SubscriberUser user) { |
| 88 | XosFunctionDescriptor xfd = XosFunctionDescriptor.URL_FILTER; | 89 | XosFunctionDescriptor xfd = XosFunctionDescriptor.URL_FILTER; |
| 89 | UrlFilterMemento memo = (UrlFilterMemento) user.getMemento(xfd); | 90 | UrlFilterMemento memo = (UrlFilterMemento) user.getMemento(xfd); |
| 90 | - return xfd.id() + "/" + memo.level(); | 91 | + return String.format(URI_PATTERN, xfd.id(), memo.level()); |
| 91 | } | 92 | } |
| 92 | } | 93 | } | ... | ... |
-
Please register or login to post a comment