void initialize ( HostContext hostContext ) throws InvalidKeyException , URISyntaxException , StorageException { this . hostContext = hostContext ; if ( this . storageContainerName == null ) { this . storageContainerName = this . hostContext . getEventHubPath ( ) ; } // Validate that the event hub name is also a legal storage container name. // Regex pattern is copied from .NET version. The syntax for Java regexes seems to be the same. // Error message is also copied from .NET version. Pattern p = Pattern . compile ( "^(?-i)(?:[a-z0-9]|(?<=[0-9a-z])-(?=[0-9a-z])){3,63}$" ) ; Matcher m = p . matcher ( this . storageContainerName ) ; if ( ! m . find ( ) ) { throw new IllegalArgumentException ( "EventHub names must conform to the following rules to be able to use it with EventProcessorHost: " + "Must start with a letter or number, and can contain only letters, numbers, and the dash (-) character. " + "Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names. " + "All letters in a container name must be lowercase. " + "Must be from 3 to 63 characters long." ) ; } this . storageClient = CloudStorageAccount . parse ( this . storageConnectionString ) . createCloudBlobClient ( ) ; this . eventHubContainer = this . storageClient . getContainerReference ( this . storageContainerName ) ; // storageBlobPrefix is either empty or a real user-supplied string. Either way we can just // stick it on the front and get the desired result. this . consumerGroupDirectory = this . eventHubContainer . getDirectoryReference ( this . storageBlobPrefix + this . hostContext . getConsumerGroupName ( ) ) ; this . gson = new Gson ( ) ; this . leaseOperationOptions . setMaximumExecutionTimeInMs ( this . hostContext . getPartitionManagerOptions ( ) . getLeaseDurationInSeconds ( ) * 1000 ) ; this . storageClient . setDefaultRequestOptions ( this . leaseOperationOptions ) ; this . checkpointOperationOptions . setMaximumExecutionTimeInMs ( this . hostContext . getPartitionManagerOptions ( ) . getCheckpointTimeoutInSeconds ( ) * 1000 ) ; // The only option that .NET sets on renewRequestOptions is ServerTimeout, which doesn't exist in Java equivalent. // Keep it separate in case we need to change something later. // Only used for leases, not checkpoints, so set max execution time to lease value this . renewRequestOptions . setMaximumExecutionTimeInMs ( this . hostContext . getPartitionManagerOptions ( ) . getLeaseDurationInSeconds ( ) * 1000 ) ; }
hence we don t want it in the constructor .