|
16 | 16 | */
|
17 | 17 | package com.alipay.sofa.registry.server.meta.cleaner;
|
18 | 18 |
|
| 19 | +import com.alipay.remoting.util.StringUtils; |
19 | 20 | import com.alipay.sofa.registry.cache.ConsecutiveSuccess;
|
20 | 21 | import com.alipay.sofa.registry.common.model.console.PersistenceData;
|
21 | 22 | import com.alipay.sofa.registry.common.model.console.PersistenceDataBuilder;
|
|
24 | 25 | import com.alipay.sofa.registry.common.model.metaserver.cleaner.AppRevisionSliceRequest;
|
25 | 26 | import com.alipay.sofa.registry.common.model.store.AppRevision;
|
26 | 27 | import com.alipay.sofa.registry.jdbc.config.MetadataConfig;
|
| 28 | +import com.alipay.sofa.registry.jdbc.convertor.AppRevisionDomainConvertor; |
27 | 29 | import com.alipay.sofa.registry.log.Logger;
|
28 | 30 | import com.alipay.sofa.registry.log.LoggerFactory;
|
29 | 31 | import com.alipay.sofa.registry.server.meta.MetaLeaderService;
|
|
35 | 37 | import com.alipay.sofa.registry.store.api.date.DateNowRepository;
|
36 | 38 | import com.alipay.sofa.registry.store.api.repository.AppRevisionRepository;
|
37 | 39 | import com.alipay.sofa.registry.util.ConcurrentUtils;
|
| 40 | +import com.alipay.sofa.registry.util.JsonUtils; |
38 | 41 | import com.alipay.sofa.registry.util.StringFormatter;
|
39 | 42 | import com.alipay.sofa.registry.util.WakeUpLoopRunnable;
|
40 | 43 | import com.google.common.collect.Lists;
|
@@ -143,11 +146,46 @@ void markDeleted() {
|
143 | 146 | appRevisionRepository.getExpired(
|
144 | 147 | dateBeforeNow(metadataConfig.getRevisionRenewIntervalMinutes() * 5),
|
145 | 148 | metaServerConfig.getAppRevisionMaxRemove());
|
| 149 | + // before markDeleted refresh app revision switch |
| 150 | + appRevisionSwitchRefresh(); |
146 | 151 | for (AppRevision revision : expired) {
|
147 | 152 | revision.setDeleted(true);
|
148 |
| - appRevisionRepository.replace(revision); |
149 |
| - LOG.info("mark deleted revision: {}", revision.getRevision()); |
150 |
| - ConcurrentUtils.sleepUninterruptibly(10, TimeUnit.MILLISECONDS); |
| 153 | + try { |
| 154 | + appRevisionRepository.replace(revision); |
| 155 | + LOG.info("mark deleted revision: {}", revision.getRevision()); |
| 156 | + ConcurrentUtils.sleepUninterruptibly(10, TimeUnit.MILLISECONDS); |
| 157 | + } catch (Throwable e) { |
| 158 | + LOG.error("mark deleted revision failed: {}", revision.getRevision(), e); |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | + private void appRevisionSwitchRefresh() { |
| 164 | + DBResponse<PersistenceData> ret = |
| 165 | + provideDataService.queryProvideData(ValueConstants.APP_REVISION_WRITE_SWITCH_DATA_ID); |
| 166 | + AppRevisionDomainConvertor.EnableConfig enableConfig = null; |
| 167 | + if (ret.getOperationStatus() == OperationStatus.SUCCESS) { |
| 168 | + PersistenceData data = ret.getEntity(); |
| 169 | + String switchString = data.getData(); |
| 170 | + if (StringUtils.isNotBlank(switchString)) { |
| 171 | + try { |
| 172 | + enableConfig = |
| 173 | + JsonUtils.read(switchString, AppRevisionDomainConvertor.EnableConfig.class); |
| 174 | + } catch (Throwable e) { |
| 175 | + LOG.error("Decode appRevision write switch failed", e); |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | + if (enableConfig != null) { |
| 180 | + LOG.info( |
| 181 | + "appRevisionSwitch prev={}/{}", |
| 182 | + AppRevisionDomainConvertor.getEnableConfig().isServiceParams(), |
| 183 | + AppRevisionDomainConvertor.getEnableConfig().isServiceParamsLarge()); |
| 184 | + AppRevisionDomainConvertor.setEnableConfig(enableConfig); |
| 185 | + LOG.info( |
| 186 | + "appRevisionSwitch update={}/{}", |
| 187 | + enableConfig.isServiceParams(), |
| 188 | + enableConfig.isServiceParamsLarge()); |
151 | 189 | }
|
152 | 190 | }
|
153 | 191 |
|
|
0 commit comments