| 217 | |
| 218 | |
| 219 | class DefaultEndPointFactory(EndPointFactory): |
| 220 | |
| 221 | port = None |
| 222 | """ |
| 223 | If no port is discovered in the row, this is the default port |
| 224 | used for endpoint creation. |
| 225 | """ |
| 226 | |
| 227 | def __init__(self, port=None): |
| 228 | self.port = port |
| 229 | |
| 230 | def create(self, row): |
| 231 | # TODO next major... move this class so we don't need this kind of hack |
| 232 | from cassandra.metadata import _NodeInfo |
| 233 | addr = _NodeInfo.get_broadcast_rpc_address(row) |
| 234 | port = _NodeInfo.get_broadcast_rpc_port(row) |
| 235 | if port is None: |
| 236 | port = self.port if self.port else 9042 |
| 237 | |
| 238 | # create the endpoint with the translated address |
| 239 | # TODO next major, create a TranslatedEndPoint type |
| 240 | return DefaultEndPoint( |
| 241 | self.cluster.address_translator.translate(addr), |
| 242 | port) |
| 243 | |
| 244 | |
| 245 | @total_ordering |