Committed by
Gerrit Code Review
ONOS-1731 Fixed app gossip store & manager to deal with staggered app load on startup.
Change-Id: Ie88f5659646c11b906a63204f97083b6deb64adb
Showing
2 changed files
with
22 additions
and
2 deletions
... | @@ -69,10 +69,16 @@ public class ApplicationManager implements ApplicationService, ApplicationAdminS | ... | @@ -69,10 +69,16 @@ public class ApplicationManager implements ApplicationService, ApplicationAdminS |
69 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 69 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
70 | protected EventDeliveryService eventDispatcher; | 70 | protected EventDeliveryService eventDispatcher; |
71 | 71 | ||
72 | + private boolean initializing; | ||
73 | + | ||
72 | @Activate | 74 | @Activate |
73 | public void activate() { | 75 | public void activate() { |
74 | eventDispatcher.addSink(ApplicationEvent.class, listenerRegistry); | 76 | eventDispatcher.addSink(ApplicationEvent.class, listenerRegistry); |
77 | + | ||
78 | + initializing = true; | ||
75 | store.setDelegate(delegate); | 79 | store.setDelegate(delegate); |
80 | + initializing = false; | ||
81 | + | ||
76 | log.info("Started"); | 82 | log.info("Started"); |
77 | } | 83 | } |
78 | 84 | ||
... | @@ -207,8 +213,12 @@ public class ApplicationManager implements ApplicationService, ApplicationAdminS | ... | @@ -207,8 +213,12 @@ public class ApplicationManager implements ApplicationService, ApplicationAdminS |
207 | private synchronized void installAppFeatures(Application app) throws Exception { | 213 | private synchronized void installAppFeatures(Application app) throws Exception { |
208 | for (String name : app.features()) { | 214 | for (String name : app.features()) { |
209 | Feature feature = featuresService.getFeature(name); | 215 | Feature feature = featuresService.getFeature(name); |
210 | - if (!featuresService.isInstalled(feature)) { | 216 | + if (feature != null && !featuresService.isInstalled(feature)) { |
211 | featuresService.installFeature(name); | 217 | featuresService.installFeature(name); |
218 | + } else if (feature == null && !initializing) { | ||
219 | + // Suppress feature-not-found reporting during startup since these | ||
220 | + // can arise naturally from the staggered cluster install. | ||
221 | + log.warn("Feature {} not found", name); | ||
212 | } | 222 | } |
213 | } | 223 | } |
214 | } | 224 | } |
... | @@ -216,8 +226,10 @@ public class ApplicationManager implements ApplicationService, ApplicationAdminS | ... | @@ -216,8 +226,10 @@ public class ApplicationManager implements ApplicationService, ApplicationAdminS |
216 | private synchronized void uninstallAppFeatures(Application app) throws Exception { | 226 | private synchronized void uninstallAppFeatures(Application app) throws Exception { |
217 | for (String name : app.features()) { | 227 | for (String name : app.features()) { |
218 | Feature feature = featuresService.getFeature(name); | 228 | Feature feature = featuresService.getFeature(name); |
219 | - if (featuresService.isInstalled(feature)) { | 229 | + if (feature != null && featuresService.isInstalled(feature)) { |
220 | featuresService.uninstallFeature(name); | 230 | featuresService.uninstallFeature(name); |
231 | + } else if (feature == null) { | ||
232 | + log.warn("Feature {} not found", name); | ||
221 | } | 233 | } |
222 | } | 234 | } |
223 | } | 235 | } | ... | ... |
... | @@ -85,6 +85,8 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -85,6 +85,8 @@ import static org.slf4j.LoggerFactory.getLogger; |
85 | public class GossipApplicationStore extends ApplicationArchive | 85 | public class GossipApplicationStore extends ApplicationArchive |
86 | implements ApplicationStore { | 86 | implements ApplicationStore { |
87 | 87 | ||
88 | + private static final int MAX_LOAD_RETRIES = 3; | ||
89 | + | ||
88 | private final Logger log = getLogger(getClass()); | 90 | private final Logger log = getLogger(getClass()); |
89 | 91 | ||
90 | private static final MessageSubject APP_BITS_REQUEST = new MessageSubject("app-bits-request"); | 92 | private static final MessageSubject APP_BITS_REQUEST = new MessageSubject("app-bits-request"); |
... | @@ -163,11 +165,17 @@ public class GossipApplicationStore extends ApplicationArchive | ... | @@ -163,11 +165,17 @@ public class GossipApplicationStore extends ApplicationArchive |
163 | */ | 165 | */ |
164 | private void loadFromDisk() { | 166 | private void loadFromDisk() { |
165 | for (String name : getApplicationNames()) { | 167 | for (String name : getApplicationNames()) { |
168 | + for (int i = 0; i < MAX_LOAD_RETRIES; i++) { | ||
169 | + try { | ||
166 | Application app = create(getApplicationDescription(name), false); | 170 | Application app = create(getApplicationDescription(name), false); |
167 | if (app != null && isActive(app.id().name())) { | 171 | if (app != null && isActive(app.id().name())) { |
168 | activate(app.id(), false); | 172 | activate(app.id(), false); |
169 | // load app permissions | 173 | // load app permissions |
170 | } | 174 | } |
175 | + } catch (Exception e) { | ||
176 | + log.warn("Unable to load application {} from disk; retrying", name); | ||
177 | + } | ||
178 | + } | ||
171 | } | 179 | } |
172 | } | 180 | } |
173 | 181 | ... | ... |
-
Please register or login to post a comment