2017-03-08 4 views
0

ラズベリーPIでKAAクライアントSDK(JAVA)を起動すると、CPU使用率が最大100%になります。できるだけ早く私は、CPU使用率が通常のPI on kaaクライアントの起動時に高いCPU使用率

に戻って落ちるプロセスを殺す、以下のように私はラズベリーパイに

public class NotificationSystemTestApp { 

    private static final Logger LOG = LoggerFactory.getLogger(NotificationSystemTestApp.class); 

    public static void main(String[] args) throws InterruptedException { 
     /*System.out.println(encryptString("abcd", "12332sd1133sdssd45")); 
     return;*/ 
     new NotificationSystemTestApp().launch(); 
    } 

    private void launch() throws InterruptedException { 
     // Create client for Kaa SDK 

     final KaaClient kaaClient; 
     DesktopKaaPlatformContext desktopKaaPlatformContext = new DesktopKaaPlatformContext(); 
     final CountDownLatch startupLatch = new CountDownLatch(1); 
     kaaClient = Kaa.newClient(desktopKaaPlatformContext, new SimpleKaaClientStateListener() { 
      @Override 
      public void onStarted() { 
       LOG.info("--= Kaa client started =--"); 
       startupLatch.countDown(); 
      } 

      @Override 
      public void onStopped() { 
       LOG.info("--= Kaa client stopped =--"); 
      } 
     }, true); 

     kaaClient.setProfileContainer(new ProfileContainer() { 
      public ClientProfile getProfile() { 
       return new ClientProfile() {{ 
        setClientProfileInfo(new ProfileInfo() {{ 
         setRidlrId("R_00001"); 
         setStationName("Mumbai"); 
         setEquipmentId("EQ0006"); 
         setStationId("5"); 
        }}); 
       }}; 
      } 
     }); 
     // Registering listener for topic updates 

     kaaClient.start(); 
     startupLatch.await(); 

     kaaClient.addTopicListListener(new NotificationTopicListListener() { 
      public void onListUpdated(List<Topic> topicList) { 
       System.out.println("Topic list updated!"); 
       for (Topic topic : topicList) { 
        LOG.info("Received topic with id {} and name {}", topic.getId(), topic.getName()); 
       } 
      } 
     }); 

     final ScanInfo scanInfo = new ScanInfo() {{ 
      setDestinationId("12"); 
      setSourceId("3"); 
      setEquipmentId("R_00001"); 
      setScanTime(System.currentTimeMillis()/1000); 
      setEvent("ENTRY"); 
      setTransactionId(UUID.randomUUID().toString()); 
     }}; 

     kaaClient.attachEndpoint(new EndpointAccessToken("1234"), new OnAttachEndpointOperationCallback() { 
      @Override 
      public void onAttach(SyncResponseResultType result, EndpointKeyHash resultContext) { 

      } 
     }); 
     kaaClient.attachUser("user1", "1234", new UserAttachCallback() { 
      public void onAttachResult(UserAttachResponse response) { 
       System.out.println("Attach User Success - " + response.getResult()); 
      } 
     }); 


     try { 
      Thread.sleep(2000); 
     } catch (InterruptedException e) { 
      LOG.error("FATA", e); 
     } 


     LOG.debug("End Point key hash - " + kaaClient.getEndpointKeyHash()); 
     while (true) { 
      kaaClient.addLogRecord(new LoggerSchema() {{ 
       setData(""); 
       setMessageType(""); 
      }}); 
      Thread.sleep(10); 
     } 
    } 
} 

おかげで、 RizwanをKAAクライアントを始めていますKAAを開始するために使用したコードスニペットです

答えて

0

私が見てきたように、Kaaサーバへのアップロードのためにログレコードを絶えず追加しています。遅延はわずか10ミリ秒で、アプリケーションを実行しているRaspberry PIシステムでは短すぎる可能性があります。

構成によっては、Kaaクライアントが各ログレコードにかなりの処理オーバーヘッドを追加し、他のJavaスレッドで処理すると、CPUが常に新しいレコードの追加や処理をスピンさせる可能性があります。

'while(true)'ループの遅延を増やして、さまざまなログアップロード設定でCPU使用率を確認してください。

この情報では問題を解決できない場合は、KaaクライアントとKaaサーバーのログを追加して調査してください。