1
public class RiakSearch {
public static final String RIAK_SERVER = "10.11.172.17";

private static RiakCluster setUpCluster() throws UnknownHostException {
    // This example will use only one node listening on localhost:10017
    RiakNode node = new RiakNode.Builder()
            .withRemoteAddress("10.11.172.17")
            .withAuth("administrator", "password@123", null).build();

    // This cluster object takes our one node as an argument
    RiakCluster cluster = new RiakCluster.Builder(node).build();

    // The cluster must be started to work, otherwise you will see errors
    cluster.start();

    return cluster;
}

public void uploadSchema() {
    try {
        RiakCluster cluster = setUpCluster();
        RiakClient client = new RiakClient(cluster);
        System.out.println("Client object successfully created");
        File xml = new File("blog_post_schema.xml");
        String xmlString = FileUtils.readFileToString(xml);
        YokozunaSchema schema = new YokozunaSchema("blog_post_schema",
                xmlString);
        StoreSchema storeSchemaOp = new StoreSchema.Builder(schema).build();
        client.execute(storeSchemaOp);
    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    RiakSearch obj = new RiakSearch();
    obj.uploadSchema();

}

}

java.util.concurrent.ExecutionException:com.basho.riak.client.core.netty.RiakResponseException:未知消息代码:com.basho.riak.client.core.FutureOperation.get(FutureOperation.java:260) 处的 56 .basho.riak.client.api.commands.CoreFutureAdapter.get(CoreFutureAdapter.java:52) 在 com.basho.riak.client.api.RiakCommand.execute(RiakCommand.java:89) 在 com.basho.riak.client .api.RiakClient.execute(RiakClient.java:293) at com.search.RiakSearch.main(RiakSearch.java:64) 原因:com.basho.riak.client.core.netty.RiakResponseException:未知消息代码:56在 com.basho.riak.client.core.netty.RiakResponseHandler.channelRead(RiakResponseHandler.java:52) 在 io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:84) 在 io.netty.channel。DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:153) 在 io.netty.channel.PausableChannelEventExecutor.invokeChannelRead(PausableChannelEventExecutor.java:86) 在 io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:389) 在 io.netty.handler .codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:243) at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103) at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:84) at io.netty.channel.PausableChannelEventExecutor.invokeChannelRead(PausableChannelEventExecutor.java:86) 在 io.netty.channel 的 io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:153)。AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:389) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:956) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:127) at io .netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:514) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:471) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop .java:385) 在 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:351) 在 io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) 在 io.netty.util .internal.chmv8.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1412) 在 io.netty.util。internal.chmv8.ForkJoinTask.doExec(ForkJoinTask.java:280) 在 io.netty.util.internal.chmv8.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:877) 在 io.netty.util.internal.chmv8.ForkJoinPool。扫描(ForkJoinPool.java:1706)在 io.netty.util.internal.chmv8.ForkJoinPool.runWorker(ForkJoinPool.java:1661)在 io.netty.util.internal.chmv8.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:126)

4

2 回答 2

4

确保 Solr 已实际启动。默认情况下,Riak 2.x 中禁用搜索。为了启用它,将search/etc/riak/riak.conf 中的属性更改为on. 然后重启Riak。

于 2015-09-10T09:10:57.373 回答
1

我有类似的问题 RiakError: 'Unknown message code: 56'

我通过更改“riak.conf”文件中的搜索参数来解决它这是文件位置,如果您使用的是mac并通过brew安装

/usr/local/Cellar/riak/2.2.2/libexec/etc/riak.conf

这是我从关闭更改为打开的代码行

## To enable Search set this 'on'.
## 
## Default: off
## 
## Acceptable values:
##   - on or off
search = on

我发现文档解释有点难以理解,但或多或​​少是解决问题的参考。

于 2017-05-21T19:11:42.410 回答