解析云代码 - 添加到阵列

时间:2017-11-28 19:32:50

标签: javascript parse-platform cloud parse-server

使用我的云代码尝试了不同变化的负载,但我无法使其工作。基本上我有一个推送通知功能,在这个功能中我想要一个对象添加到PFUser的阵列,但是你不能在Xcode中使用一个主密钥,所以这里有#s我有什么:

17/11/30 01:53:40 INFO Worker: Retrying connection to master (attempt # 16) 17/11/30 01:53:40 INFO Worker: Connecting to master
10.8.9.13:7077... 17/11/30 01:53:40 WARN Worker: Failed to connect to master 10.8.9.13:7077 org.apache.spark.SparkException: Exception thrown in awaitResult    
at org.apache.spark.rpc.RpcTimeout$$anonfun$1.applyOrElse(RpcTimeout.scala:77)  
at org.apache.spark.rpc.RpcTimeout$$anonfun$1.applyOrElse(RpcTimeout.scala:75)  
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)    
at org.apache.spark.rpc.RpcTimeout$$anonfun$addMessageIfTimeout$1.applyOrElse(RpcTimeout.scala:59)  
at org.apache.spark.rpc.RpcTimeout$$anonfun$addMessageIfTimeout$1.applyOrElse(RpcTimeout.scala:59)  
at scala.PartialFunction$OrElse.apply(PartialFunction.scala:167)    
at org.apache.spark.rpc.RpcTimeout.awaitResult(RpcTimeout.scala:83)     
at org.apache.spark.rpc.RpcEnv.setupEndpointRefByURI(RpcEnv.scala:100)  
at org.apache.spark.rpc.RpcEnv.setupEndpointRef(RpcEnv.scala:108)   
at org.apache.spark.deploy.worker.Worker$$anonfun$org$apache$spark$deploy$worker$Worker$$tryRegisterAllMasters$1$$anon$1.run(Worker.scala:218)  
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)  
at java.util.concurrent.FutureTask.run(FutureTask.java:266)     
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)  
at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: java.io.EOFException    
at java.io.DataInputStream.readFully(DataInputStream.java:197)  
at java.io.DataInputStream.readUTF(DataInputStream.java:609)    
at java.io.DataInputStream.readUTF(DataInputStream.java:564)    
at org.apache.spark.rpc.netty.RequestMessage$.readRpcAddress(NettyRpcEnv.scala:582)     
at org.apache.spark.rpc.netty.RequestMessage$.apply(NettyRpcEnv.scala:592)  
at org.apache.spark.rpc.netty.NettyRpcHandler.internalReceive(NettyRpcEnv.scala:651)    
at org.apache.spark.rpc.netty.NettyRpcHandler.receive(NettyRpcEnv.scala:636)    
at org.apache.spark.network.server.TransportRequestHandler.processRpcRequest(TransportRequestHandler.java:157)  
at org.apache.spark.network.server.TransportRequestHandler.handle(TransportRequestHandler.java:105)     
at org.apache.spark.network.server.TransportChannelHandler.channelRead(TransportChannelHandler.java:118)    
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)   
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)   
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)   
at org.apache.spark.network.util.TransportFrameDecoder.channelRead(TransportFrameDecoder.java:85)   
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)   
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)    
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)     
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)     
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)  
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:643)  
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:566)    
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)     
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)     
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131)     
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)    
at java.lang.Thread.run(Thread.java:748)


at org.apache.spark.network.client.TransportResponseHandler.handle(TransportResponseHandler.java:189)   
at org.apache.spark.network.server.TransportChannelHandler.channelRead(TransportChannelHandler.java:120)    
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)   
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)   
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)   
at org.apache.spark.network.util.TransportFrameDecoder.channelRead(TransportFrameDecoder.java:85)   
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)     
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:346)   
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)    
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)     
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:353)     
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)     
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)  
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652)  
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575)    
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489)     
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)     
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)     
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)    
    ... 1 more 17/11/30 01:54:43 ERROR Worker: All masters are unresponsive! Giving up.

Xcode云功能我提供了正确的信息,功能到底......只是函数没有因某种原因设置通知

1 个答案:

答案 0 :(得分:0)

我最终弄清楚了这篇文章的答案。这不起作用的原因是因为我需要首先在单独的查询中获取用户对象,然后使用主密钥保存它。我还发现,有一个函数可以将数据附加到现有数组而无需创建另一个数据(parseObject.add()):

var userQ   =   new Parse.Query(Parse.User);
userQ.get(userid, {
    success: function(theuser) {
        console.log("### got userrrrrrrrrr!");
        theuser.add("notifications", n_object);
        theuser.save(null, {useMasterKey:true});
    },
    error: function(object, error) {
        // The object was not retrieved successfully.
        // error is a Parse.Error with an error code and message.
    }
});

这组代码在之前执行:

response.success('success. end of iospush');