日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

本文介紹了如何修復(fù)因引發(fā)java.lang.IlLegalStateException而引發(fā)的Hazelcast:未為EntryProcessor啟用用戶代碼部署的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在嘗試使用EntryProcessor為我們的應(yīng)用程序設(shè)置一個(gè)用于Hazelcast的代碼。為了分析為什么EntryProcessor的代碼在我們的應(yīng)用程序中不起作用,我嘗試在我的本地計(jì)算機(jī)上設(shè)置一個(gè)類似的示例來重現(xiàn)該問題。然而,即使在我可以復(fù)制相同的問題之前,我還面臨著另一個(gè)問題,該問題應(yīng)該如下所示:

    從here下載Hazelcast IMDG 3.10.6。然后將其解壓縮。
    新建Java應(yīng)用程序并添加main page的Java客戶端–>EntryProcessor下給出的代碼。
    將Hazelcast-3.10.6和Hazelcast-Client-3.10.6 Jars添加到解壓縮的Hazelcast文件夾的lib文件夾下。
    從bin文件夾下的start.bat文件啟動(dòng)Hazelcast成員(服務(wù)器)。
    運(yùn)行步驟2中給出的Java客戶端代碼。

我還粘貼了下面的Java客戶端代碼以供參考。

package client;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.config.ClientUserCodeDeploymentConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.map.AbstractEntryProcessor;

import java.io.Serializable;
import java.util.Map;

public class EntryProcessorSample {

    public static class IncEntryProcessor extends AbstractEntryProcessor<String, Integer> implements Serializable {
        @Override
        public Object process(Map.Entry<String, Integer> entry) {
            // Get the value passed
            int oldValue = entry.getValue();
            // Update the value
            int newValue = oldValue + 1;
            // Update the value back to the entry stored in the Hazelcast Member this EntryProcessor is running on.
            entry.setValue(newValue);
            // No need to return anything back to the caller, we can return whatever we like here.
            return null;
        }
    }

    public static void main(String[] args) {
        // Enable Code Deployment from this Client classpath to the Cluster Members classpath
        // User Code Deployment needs to be enabled on the Cluster Members as well.
        ClientConfig config = new ClientConfig();
        ClientUserCodeDeploymentConfig userCodeDeploymentConfig = config.getUserCodeDeploymentConfig();
        userCodeDeploymentConfig.setEnabled(true);
        userCodeDeploymentConfig.addClass(EntryProcessorSample.IncEntryProcessor.class);
        // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
        HazelcastInstance hz = HazelcastClient.newHazelcastClient(config);
        // Get the Distributed Map from Cluster.
        IMap<String, Integer> map = hz.getMap("my-distributed-map");
        // Put the integer value of 0 into the Distributed Map
        map.put("key", 0);
        // Run the IncEntryProcessor class on the Hazelcast Cluster Member holding the key called "key"
        map.executeOnKey("key", new IncEntryProcessor());
        // Show that the IncEntryProcessor updated the value.
        System.out.println("new value:" + map.get("key"));
        // Shutdown this Hazelcast Client
        hz.shutdown();
    }
} 

我希望代碼運(yùn)行時(shí)沒有任何問題,因?yàn)閔azelcast site中給出的Java客戶端的Map示例運(yùn)行得很好。另外,由于我們顯式啟用了客戶端配置的用戶代碼部署,我不明白為什么會(huì)出現(xiàn)此問題。

推薦答案

您也需要在成員端開啟User Code Deployment。

這篇關(guān)于如何修復(fù)因引發(fā)java.lang.IlLegalStateException而引發(fā)的Hazelcast:未為EntryProcessor啟用用戶代碼部署的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,

分享到:
標(biāo)簽:Java 代碼 修復(fù) 啟用 引發(fā) 用戶 部署
用戶無頭像

網(wǎng)友整理

注冊時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定