-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3.0] Refactor application/module deploy processing and events (#8824)
* Init SpringExtensionInjector in DubboInfraBeanRegisterPostProcessor * Refactor application/module deployer start and listener * Refactor Dubbo spring initialization and events * Adjust shutdown hook callback call chain * Fix license * Add spring context module reload test * Fix deadlock of ApplicationModel module while destroy * Catch error while add/remove java shutdown hook * Waiting for dubbo start in spring application * polish deploy log * Rename DubboSpringInitializaionXxx to DubboSpringInitXxx * Fix compile error * fix tests
- Loading branch information
Showing
113 changed files
with
1,826 additions
and
741 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
dubbo-common/src/main/java/org/apache/dubbo/common/deploy/AbstractDeployer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* 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.deploy; | ||
|
||
import org.apache.dubbo.rpc.model.ScopeModel; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static org.apache.dubbo.common.deploy.DeployState.FAILED; | ||
import static org.apache.dubbo.common.deploy.DeployState.PENDING; | ||
import static org.apache.dubbo.common.deploy.DeployState.STARTED; | ||
import static org.apache.dubbo.common.deploy.DeployState.STARTING; | ||
import static org.apache.dubbo.common.deploy.DeployState.STOPPED; | ||
import static org.apache.dubbo.common.deploy.DeployState.STOPPING; | ||
|
||
public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer<E> { | ||
|
||
private volatile DeployState state = PENDING; | ||
|
||
protected AtomicBoolean initialized = new AtomicBoolean(false); | ||
|
||
private List<DeployListener<E>> listeners = new ArrayList<>(); | ||
|
||
private E scopeModel; | ||
|
||
public AbstractDeployer(E scopeModel) { | ||
this.scopeModel = scopeModel; | ||
} | ||
|
||
@Override | ||
public boolean isPending() { | ||
return state == PENDING; | ||
} | ||
|
||
@Override | ||
public boolean isRunning() { | ||
return state == STARTING || state == STARTED; | ||
} | ||
|
||
@Override | ||
public boolean isStarted() { | ||
return state == STARTED; | ||
} | ||
|
||
@Override | ||
public boolean isStarting() { | ||
return state == STARTING; | ||
} | ||
|
||
@Override | ||
public boolean isStopping() { | ||
return state == STOPPING; | ||
} | ||
|
||
@Override | ||
public boolean isStopped() { | ||
return state == STOPPED; | ||
} | ||
|
||
@Override | ||
public boolean isFailed() { | ||
return state == FAILED; | ||
} | ||
|
||
@Override | ||
public DeployState getState() { | ||
return state; | ||
} | ||
|
||
@Override | ||
public void addDeployListener(DeployListener<E> listener) { | ||
listeners.add(listener); | ||
} | ||
|
||
@Override | ||
public void removeDeployListener(DeployListener<E> listener) { | ||
listeners.remove(listener); | ||
} | ||
|
||
protected void setStarting() { | ||
this.state = STARTING; | ||
for (DeployListener<E> listener : listeners) { | ||
listener.onStarting(scopeModel); | ||
} | ||
} | ||
|
||
protected void setStarted() { | ||
this.state = STARTED; | ||
for (DeployListener<E> listener : listeners) { | ||
listener.onStarted(scopeModel); | ||
} | ||
} | ||
protected void setStopping() { | ||
this.state = STOPPING; | ||
for (DeployListener<E> listener : listeners) { | ||
listener.onStopping(scopeModel); | ||
} | ||
} | ||
|
||
protected void setStopped() { | ||
this.state = STOPPED; | ||
for (DeployListener<E> listener : listeners) { | ||
listener.onStopped(scopeModel); | ||
} | ||
} | ||
|
||
protected void setFailed(Throwable cause) { | ||
this.state = FAILED; | ||
for (DeployListener<E> listener : listeners) { | ||
listener.onFailure(scopeModel, cause); | ||
} | ||
} | ||
|
||
public boolean isInitialized() { | ||
return initialized.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
dubbo-common/src/main/java/org/apache/dubbo/common/deploy/DeployListenerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.deploy; | ||
|
||
import org.apache.dubbo.rpc.model.ScopeModel; | ||
|
||
public class DeployListenerAdapter<E extends ScopeModel> implements DeployListener<E>{ | ||
@Override | ||
public void onStarting(E scopeModel) { | ||
} | ||
|
||
@Override | ||
public void onStarted(E scopeModel) { | ||
} | ||
|
||
@Override | ||
public void onStopping(E scopeModel) { | ||
} | ||
|
||
@Override | ||
public void onStopped(E scopeModel) { | ||
} | ||
|
||
@Override | ||
public void onFailure(E scopeModel, Throwable cause) { | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
dubbo-common/src/main/java/org/apache/dubbo/common/deploy/DeployState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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.deploy; | ||
|
||
/** | ||
* Deploy state enum | ||
*/ | ||
public enum DeployState { | ||
PENDING, STARTING, STARTED, STOPPING, STOPPED, FAILED | ||
} |
Oops, something went wrong.