Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

saving changes.

  • Loading branch information...
commit ca4576fee97a1b2d69e2d88cb55c5f35fa608b51 1 parent 477f6fc
Neil authored
View
1  clc/modules/storage-manager/src/main/java/edu/ucsb/eucalyptus/cloud/ws/ObjectReader.java
@@ -98,6 +98,7 @@ public void run() {
}
try {
+ LOG.warn("putting data");
getQueue.put(WalrusDataMessage.StartOfData(bytesRemaining));
while (bytesRemaining > 0) {
View
27 clc/modules/storage-manager/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusManager.java
@@ -43,8 +43,13 @@
import edu.ucsb.eucalyptus.storage.StorageManager;
import edu.ucsb.eucalyptus.storage.fs.FileIO;
import edu.ucsb.eucalyptus.util.*;
+import com.eucalyptus.ws.MappingHttpResponse;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.netty.channel.Channel;
+
import org.apache.log4j.Logger;
import org.apache.tools.ant.util.DateUtils;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
import java.io.File;
import java.io.IOException;
@@ -56,6 +61,10 @@
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import com.eucalyptus.ws.handlers.WalrusRESTBinding;
+import java.io.RandomAccessFile;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelFutureListener;
+import org.jboss.netty.handler.stream.ChunkedFile;
public class WalrusManager {
private static Logger LOG = Logger.getLogger( WalrusManager.class );
@@ -1242,11 +1251,23 @@ public GetObjectResponseType getObject(GetObjectType request) throws EucalyptusC
request.setRandomKey(randomKey);
LinkedBlockingQueue<WalrusDataMessage> getQueue = WalrusRESTBinding.getReadMessenger().getQueue(key, randomKey);
- ObjectReader reader = new ObjectReader(bucketName, objectName, objectInfo.getSize(), getQueue, deleteAfterGet, null, storageManager);
- reader.start();
+ //ObjectReader reader = new ObjectReader(bucketName, objectName, objectInfo.getSize(), getQueue, deleteAfterGet, null, storageManager);
+ //reader.start();
}
}
- reply.setEtag(objectInfo.getEtag());
+ try {
+ RandomAccessFile raf = new RandomAccessFile(new File("/disk1/eucalyptus/build/main/var/lib/eucalyptus/bukkits/" + bucketName + "/" + objectName), "r");
+
+ MappingHttpResponse httpResponse = new MappingHttpResponse( HttpVersion.HTTP_1_1 );
+ httpResponse.addHeader( HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(objectInfo.getSize()) );
+ httpResponse.addHeader( HttpHeaders.Names.CONTENT_TYPE, "binary/octet-stream" );
+ WalrusRESTBinding.channel.write(httpResponse);
+ ChannelFuture writeFuture = WalrusRESTBinding.channel.write(new ChunkedFile(raf, 0, objectInfo.getSize(), 8192));
+ writeFuture.addListener(ChannelFutureListener.CLOSE);
+ } catch(Exception ex) {
+ LOG.error(ex, ex);
+ }
+ reply.setEtag(objectInfo.getEtag());
reply.setLastModified(DateUtils.format(objectInfo.getLastModified().getTime(), DateUtils.ISO8601_DATETIME_PATTERN + ".000Z"));
reply.setSize(objectInfo.getSize());
reply.setContentType(objectInfo.getContentType());
View
4 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/MappingHttpResponse.java
@@ -22,5 +22,7 @@ public HttpResponseStatus getStatus( ) {
return status;
}
-
+ public void setStatus(final HttpResponseStatus status) {
+ this.status = status;
+ }
}
View
5 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/handlers/ServiceSinkHandler.java
@@ -23,6 +23,8 @@
import edu.ucsb.eucalyptus.msgs.EucalyptusMessage;
import edu.ucsb.eucalyptus.msgs.EventRecord;
import edu.ucsb.eucalyptus.msgs.WalrusDataRequestType;
+import edu.ucsb.eucalyptus.msgs.GetObjectResponseType;
+
@ChannelPipelineCoverage("one")
public class ServiceSinkHandler implements ChannelDownstreamHandler, ChannelUpstreamHandler{
@@ -91,7 +93,8 @@ public void run() {
}
MappingHttpResponse response = new MappingHttpResponse( message.getProtocolVersion( ) );
response.setMessage( reply );
- Channels.write( ctx.getChannel( ), response );
+ if(!(reply instanceof GetObjectResponseType))
+ Channels.write( ctx.getChannel( ), response );
}
}
}
View
24 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/handlers/WalrusOutboundHandler.java
@@ -0,0 +1,24 @@
+package com.eucalyptus.ws.handlers;
+
+import com.eucalyptus.ws.MappingHttpResponse;
+
+import org.apache.log4j.Logger;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+
+public class WalrusOutboundHandler extends MessageStackHandler {
+ private static Logger LOG = Logger.getLogger( WalrusOutboundHandler.class );
+
+ @Override
+ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) throws Exception {
+ if ( event.getMessage( ) instanceof MappingHttpResponse ) {
+ MappingHttpResponse httpResponse = ( MappingHttpResponse ) event.getMessage( );
+ EucalyptusMessage msg = (EucalyptusMessage) httpResponse.getMessage( );
+ if(msg instanceof WalrusDeleteResponseType) {
+ httpResponse.setStatus(HttpResponseStatus.NO_CONTENT);
+ }
+ }
+ }
+
+}
View
21 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/handlers/WalrusRESTBinding.java
@@ -83,18 +83,20 @@
public static final int DATA_MESSAGE_SIZE = 102400;
private LinkedBlockingQueue<WalrusDataMessage> putQueue;
private GetObjectType getObjectType;
-
+ public static Channel channel;
+
@Override
public void incomingMessage( ChannelHandlerContext ctx, MessageEvent event ) throws Exception {
- LOG.warn("Incoming message");
if ( event.getMessage( ) instanceof MappingHttpRequest ) {
MappingHttpRequest httpRequest = ( MappingHttpRequest ) event.getMessage( );
namespace = "http://s3.amazonaws.com/doc/" + WalrusProperties.NAMESPACE_VERSION;
// TODO: get real user data here too
EucalyptusMessage msg = (EucalyptusMessage) this.bind( "admin", true, httpRequest );
httpRequest.setMessage( msg );
- if(msg instanceof GetObjectType)
+ if(msg instanceof GetObjectType) {
getObjectType = (GetObjectType) msg;
+ channel = ctx.getChannel();
+ }
} else if(event.getMessage() instanceof HttpChunk) {
HttpChunk httpChunk = (HttpChunk) event.getMessage();
handleHttpChunk(httpChunk);
@@ -106,13 +108,13 @@ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) thr
if ( event.getMessage( ) instanceof MappingHttpResponse ) {
MappingHttpResponse httpResponse = ( MappingHttpResponse ) event.getMessage( );
EucalyptusMessage msg = (EucalyptusMessage) httpResponse.getMessage( );
- if(msg instanceof GetObjectResponseType) {
+ if(false) { //msg instanceof GetObjectResponseType) {
GetObjectResponseType getObjectResponse = (GetObjectResponseType) msg;
Long size = getObjectResponse.getSize();
String etag = getObjectResponse.getEtag();
httpResponse.addHeader( HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(size) );
httpResponse.addHeader( HttpHeaders.Names.CONTENT_TYPE, "binary/octet-stream" );
- Channel channel = event.getChannel();
+ Channel channel = ctx.getChannel();
channel.write(httpResponse);
WalrusDataMessenger messenger = getReadMessenger();
LinkedBlockingQueue<WalrusDataMessage> getQueue = messenger.getQueue(getObjectType.getKey(), getObjectType.getRandomKey());
@@ -124,9 +126,10 @@ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) thr
//TODO: should read size and verify
} else if(WalrusDataMessage.isData(dataMessage)) {
byte[] data = dataMessage.getPayload();
+ LOG.warn("writing data message");
channel.write(data);
} else {
-
+ return;
}
}
} catch (InterruptedException ex) {
@@ -134,6 +137,8 @@ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) thr
}
} else {
Binding binding = BindingManager.getBinding( BindingManager.sanitizeNamespace( namespace ) );
+ if(httpResponse.getMessage() != null) {
+ if(!(httpResponse.getMessage() instanceof GetObjectResponseType)) {
OMElement omMsg = binding.toOM( httpResponse.getMessage( ) );
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
omMsg.serialize( byteOut );
@@ -142,6 +147,8 @@ public void outgoingMessage( ChannelHandlerContext ctx, MessageEvent event ) thr
httpResponse.addHeader( HttpHeaders.Names.CONTENT_LENGTH, String.valueOf( buffer.readableBytes() ) );
httpResponse.addHeader( HttpHeaders.Names.CONTENT_TYPE, "text/plain" );
httpResponse.setContent( buffer );
+ }
+ }
}
}
}
@@ -1082,8 +1089,6 @@ private String getMessageString(MappingHttpRequest httpRequest) {
private void handleHttpChunk(HttpChunk httpChunk) throws Exception {
ChannelBuffer buffer = httpChunk.getContent();
- byte[] bytes = new byte[DATA_MESSAGE_SIZE];
-
try {
buffer.markReaderIndex( );
byte[] read = new byte[buffer.readableBytes( )];
View
1  clc/modules/wsstack/src/main/java/com/eucalyptus/ws/server/WalrusRESTPipeline.java
@@ -25,6 +25,7 @@
protected void addStages( List<UnrollableStage> stages ) {
stages.add( new WalrusUserAuthenticationStage( ) );
stages.add( new WalrusRESTBindingStage( ) );
+
}
@Override
View
22 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/stages/WalrusOutboundStage.java
@@ -0,0 +1,22 @@
+package com.eucalyptus.ws.stages;
+
+import org.jboss.netty.channel.ChannelPipeline;
+
+import com.eucalyptus.ws.handlers.HmacV2Handler;
+import com.eucalyptus.ws.handlers.QueryTimestampHandler;
+import com.eucalyptus.ws.handlers.RestfulMarshallingHandler;
+import com.eucalyptus.ws.handlers.WalrusAuthenticationHandler;
+
+public class WalrusOutboundStage implements UnrollableStage {
+
+ @Override
+ public String getStageName( ) {
+ return "walrus-outbound";
+ }
+
+ @Override
+ public void unrollStage( ChannelPipeline pipeline ) {
+ pipeline.addLast( "walrus-outbound", new WalrusOutboundHandler( ) );
+ }
+
+}
View
2  ...modules/wsstack/src/main/java/com/eucalyptus/ws/stages/WalrusUserAuthenticationStage.java
@@ -11,7 +11,7 @@
@Override
public String getStageName( ) {
- return "hmac-v2-user-authentication";
+ return "walrus-user-authentication";
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.