| 185 | } |
| 186 | |
| 187 | private String S3Exec(AmazonS3Client s3Client, int sid, String key, String cmd) { |
| 188 | com.amazonaws.services.s3.model.CopyObjectRequest request = |
| 189 | new com.amazonaws.services.s3.model.CopyObjectRequest(bucketname, key, bucketname, key); |
| 190 | |
| 191 | String metainfo = (String) sessionsList.get(sid - 1).get(1); |
| 192 | |
| 193 | com.amazonaws.services.s3.model.ObjectMetadata meta = new com.amazonaws.services.s3.model.ObjectMetadata(); |
| 194 | meta.addUserMetadata("cmd", cmd); |
| 195 | meta.addUserMetadata("info", metainfo); |
| 196 | request.setNewObjectMetadata(meta); |
| 197 | s3Client.copyObject(request); |
| 198 | |
| 199 | int trySum = 0; |
| 200 | while (trySum < 40) { |
| 201 | trySum++; |
| 202 | try { |
| 203 | Thread.sleep(1000); |
| 204 | String res = readS3Res(key, s3Client); |
| 205 | if (res.contains("|") && res.contains("|" + cmd + "|")) { |
| 206 | return res; |
| 207 | } |
| 208 | } catch (InterruptedException e) { |
| 209 | e.printStackTrace(); |
| 210 | } |
| 211 | } |
| 212 | return "no result"; |
| 213 | } |
| 214 | |
| 215 | private String readS3Res(String key, AmazonS3Client s3Client) { |
| 216 | StringBuffer sb = new StringBuffer(""); |