如何彻底关闭分布式ActivePivot设置?

时间:2015-02-06 14:24:49

标签: activepivot

我们有一个ActivePivot立方体,它是一个多态立方体(2个节点),其中1个节点本身是一个水平分布的立方体(8个节点)。使用JGroup TCP在Tomcat中运行以进行分发。它每天重新启动,但每次关闭(节点服务按顺序停止)时,日志中都会显示各种错误。这是无害的,但从监控的角度来看很烦人。

一天的例子(所有相同的节点):

19:04:43.100 ERROR [Pool-LongPollin][streaming] A listener dropped (5f587379-ac67-4645-8554-2e02ed739924). The number of listeners is now 1
19:04:45.767 ERROR [Pool-LongPollin][streaming] Publishing global failure
19:05:16.313 ERROR [localhost-start][core] Failed to stop feed type MDXFEED with id A1C1D8D92CF7D867F09DCB7E65077B18.0.PT0

另一天的示例(来自多个不同节点的相同错误):

19:00:17.353 ERROR [pivot-remote-0-][distribution] A safe broadcasting task could not be performed
com.quartetfs.fwk.QuartetRuntimeException: [<node name>] Cannot run a broadcasting task with a STOPPED messenger

有没有人知道关闭这样的设置的干净方法?

1 个答案:

答案 0 :(得分:2)

出现这些错误是因为在应用程序关闭时,ActivePivotManager正在积极地停止分发,而不等待每个分布式ActivePivot通知其他多维数据集已被停止。

要顺利停止分发,您可以使用DistributionUtil类中的方法。例如:

public class DistributionStopper {

protected final IActivePivotManager manager;

public DistributionStopper (IActivePivotManager manager){
    this.manager = manager;
}

public void stop(){
    // Get all the schemas from the manager
    final Collection<IActivePivotSchema> schemas = manager.getSchemas().values();

    // To store all the available messengers
    final List<IDistributedMessenger<?>> availableMessengers = new LinkedList<>();

    // Find all the messengers
    for(IActivePivotSchema schema : schemas){
        for(String pivotId : schema.getPivotIds()){
            // Retrieve the activePivot matching this id
            final IMultiVersionActivePivot pivot = schema.retrieveActivePivot(pivotId);

            if(pivot instanceof IMultiVersionDistributedActivePivot){
                IDistributedMessenger<IActivePivotSession> messenger = ((IMultiVersionDistributedActivePivot) pivot).getMessenger();
                if(messenger != null){
                    availableMessengers.add(messenger);
                }
            }
        }
    }

    // Smoothly stop the messengers
    DistributionUtil.stopMessengers(availableMessengers);
}

}

然后根据activePivotManager单例bean将此自定义类注册为Spring bean,以便在其中一个管理器之前调用其destroyMethod。

@Bean(destroyMethod="stop")
@DependsOn("activePivotManager")
public DistributionStopper distributionStopper(IActivePivotManager manager){
    return new DistributionStopper(manager);
}