Skip to content

Cloud native 2.7.5 #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ public static Wrapper getWrapper(Class<?> c) {
return OBJECT_WRAPPER;
}

Wrapper ret = WRAPPER_MAP.get(c);
if (ret == null) {
ret = makeWrapper(c);
WRAPPER_MAP.put(c, ret);
}
return ret;
return WRAPPER_MAP.computeIfAbsent(c, key -> makeWrapper(key));
}

private static Wrapper makeWrapper(Class<?> c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* The factory interface to create the instance of {@link DynamicConfiguration}
*/
@SPI("file") // 2.7.5 change the default SPI implementation
@SPI("nop") // 2.7.5 change the default SPI implementation
public interface DynamicConfigurationFactory {

DynamicConfiguration getDynamicConfiguration(URL url);
Expand Down
284 changes: 142 additions & 142 deletions dubbo-common/src/main/java/org/apache/dubbo/common/utils/Stack.java
Original file line number Diff line number Diff line change
@@ -1,143 +1,143 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.common.utils;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.List;
/**
* Stack.
*/
public class Stack<E> {
private int mSize = 0;
private List<E> mElements = new ArrayList<E>();
public Stack() {
}
/**
* push.
*
* @param ele
*/
public void push(E ele) {
if (mElements.size() > mSize) {
mElements.set(mSize, ele);
} else {
mElements.add(ele);
}
mSize++;
}
/**
* pop.
*
* @return the last element.
*/
public E pop() {
if (mSize == 0) {
throw new EmptyStackException();
}
return mElements.set(--mSize, null);
}
/**
* peek.
*
* @return the last element.
*/
public E peek() {
if (mSize == 0) {
throw new EmptyStackException();
}
return mElements.get(mSize - 1);
}
/**
* get.
*
* @param index index.
* @return element.
*/
public E get(int index) {
if (index >= mSize) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mSize);
}
return index < 0 ? mElements.get(index + mSize) : mElements.get(index);
}
/**
* set.
*
* @param index index.
* @param value element.
* @return old element.
*/
public E set(int index, E value) {
if (index >= mSize) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mSize);
}
return mElements.set(index < 0 ? index + mSize : index, value);
}
/**
* remove.
*
* @param index
* @return element
*/
public E remove(int index) {
if (index >= mSize) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mSize);
}
E ret = mElements.remove(index < 0 ? index + mSize : index);
mSize--;
return ret;
}
/**
* get stack size.
*
* @return size.
*/
public int size() {
return mSize;
}
/**
* is empty.
*
* @return empty or not.
*/
public boolean isEmpty() {
return mSize == 0;
}
/**
* clear stack.
*/
public void clear() {
mSize = 0;
mElements.clear();
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.common.utils;

import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.List;

/**
* Stack.
*/

public class Stack<E> {
private int mSize = 0;

private List<E> mElements = new ArrayList<E>();

public Stack() {
}

/**
* push.
*
* @param ele
*/
public void push(E ele) {
if (mElements.size() > mSize) {
mElements.set(mSize, ele);
} else {
mElements.add(ele);
}
mSize++;
}

/**
* pop.
*
* @return the last element.
*/
public E pop() {
if (mSize == 0) {
throw new EmptyStackException();
}
return mElements.set(--mSize, null);
}

/**
* peek.
*
* @return the last element.
*/
public E peek() {
if (mSize == 0) {
throw new EmptyStackException();
}
return mElements.get(mSize - 1);
}

/**
* get.
*
* @param index index.
* @return element.
*/
public E get(int index) {
if (index >= mSize || index + mSize < 0) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mSize);
}

return index < 0 ? mElements.get(index + mSize) : mElements.get(index);
}

/**
* set.
*
* @param index index.
* @param value element.
* @return old element.
*/
public E set(int index, E value) {
if (index >= mSize || index + mSize < 0) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mSize);
}

return mElements.set(index < 0 ? index + mSize : index, value);
}

/**
* remove.
*
* @param index
* @return element
*/
public E remove(int index) {
if (index >= mSize || index + mSize < 0) {
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mSize);
}

E ret = mElements.remove(index < 0 ? index + mSize : index);
mSize--;
return ret;
}

/**
* get stack size.
*
* @return size.
*/
public int size() {
return mSize;
}

/**
* is empty.
*
* @return empty or not.
*/
public boolean isEmpty() {
return mSize == 0;
}

/**
* clear stack.
*/
public void clear() {
mSize = 0;
mElements.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ public void setLayer(String layer) {
}

public ApplicationConfig getApplication() {
if (application != null) {
return application;
}
return ApplicationModel.getConfigManager().getApplicationOrElseThrow();
}

Expand All @@ -447,6 +450,9 @@ public void setApplication(ApplicationConfig application) {
}

public ModuleConfig getModule() {
if (module != null) {
return module;
}
return ApplicationModel.getConfigManager().getModule().orElse(null);
}

Expand Down Expand Up @@ -504,6 +510,9 @@ public void setMethods(List<? extends MethodConfig> methods) {


public MonitorConfig getMonitor() {
if (monitor != null) {
return monitor;
}
return ApplicationModel.getConfigManager().getMonitor().orElse(null);
}

Expand Down Expand Up @@ -551,7 +560,7 @@ public void setConfigCenter(ConfigCenterConfig configCenter) {
ConfigManager configManager = ApplicationModel.getConfigManager();
Collection<ConfigCenterConfig> configs = configManager.getConfigCenters();
if (CollectionUtils.isEmpty(configs)
|| configs.stream().noneMatch(existed -> existed.getAddress().equals(configCenter.getAddress()))) {
|| configs.stream().noneMatch(existed -> existed.equals(configCenter))) {
configManager.addConfigCenter(configCenter);
}
}
Expand Down Expand Up @@ -591,7 +600,14 @@ public void setScope(String scope) {

@Deprecated
public MetadataReportConfig getMetadataReportConfig() {
return metadataReportConfig;
if (metadataReportConfig != null) {
return metadataReportConfig;
}
Collection<MetadataReportConfig> metadataReportConfigs = ApplicationModel.getConfigManager().getMetadataConfigs();
if (CollectionUtils.isNotEmpty(metadataReportConfigs)) {
return metadataReportConfigs.iterator().next();
}
return null;
}

@Deprecated
Expand All @@ -601,14 +617,17 @@ public void setMetadataReportConfig(MetadataReportConfig metadataReportConfig) {
ConfigManager configManager = ApplicationModel.getConfigManager();
Collection<MetadataReportConfig> configs = configManager.getMetadataConfigs();
if (CollectionUtils.isEmpty(configs)
|| configs.stream().noneMatch(existed -> existed.getAddress().equals(metadataReportConfig.getAddress()))) {
|| configs.stream().noneMatch(existed -> existed.equals(metadataReportConfig))) {
configManager.addMetadataReport(metadataReportConfig);
}
}
}

@Deprecated
public MetricsConfig getMetrics() {
if (metrics != null) {
return metrics;
}
return ApplicationModel.getConfigManager().getMetrics().orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ModuleConfig(String name) {
setName(name);
}

@Parameter(key = "module", required = true)
@Parameter(key = "module")
public String getName() {
return name;
}
Expand Down
Loading